Amazon holiday deals See deals →ad

Mets Minor League Blog

Music theory, instruments and musicians

Mets Minor League Blog

Music theory, instruments and musicians

Linux Find File Creation Date: What Actually Works

Linux can show a file’s creation time only when the filesystem and kernel expose its birth timestamp; it is not guaranteed to exist. Check a file with stat -c '%w' file, or search with GNU find using -printf '%B+ %p\n'; a dash or blank result means the timestamp is unavailable, not that the file is new.

What Linux means by a file’s creation date

A file’s creation date usually means the time its filesystem object was created. Linux tools and documentation often call this the birth time or birth timestamp. It is distinct from the date a file’s contents were last changed, and it may not be recorded or exposed by every filesystem.

There is another important qualification: a file’s birth time does not necessarily tell you when its information was first written anywhere. Copying a file to a different filesystem generally creates a new filesystem object there, so its birth time can reflect the copy rather than the original file’s history. Archive tools and applications may preserve some timestamps, such as modification time, while creating a new object with a different birth time.

That makes the answer conditional rather than universal. If the system reports a birth time, it is useful evidence of when that particular file object was created. If it does not, Linux cannot reliably reconstruct the date from the file’s other standard timestamps.

Check one file with stat

On a typical Linux installation using GNU Coreutils, run:

stat -c '%w' -- report.txt

The %w format prints the file’s birth time in a readable date-and-time format. For example, a result might look like 2024-06-18 09:42:31.000000000 +0000. If the result is -, the system does not have a birth time available for that file through this interface.

For a numeric Unix timestamp, use %W:

stat -c '%W' -- report.txt

This prints seconds since the Unix epoch when the birth time is known; GNU stat prints 0 when it is unknown. Do not interpret that zero as proof that the file was created on January 1, 1970. It is a sentinel value for missing information. To see all timestamps and other file details together, use stat -- report.txt; GNU stat labels the creation field as “Birth” when it can provide one.

The -c option and these format codes are for GNU stat, commonly found on Linux. Minimal systems may use BusyBox, whose supported options can differ, and commands on macOS or other Unix-like systems may have different syntax. Check stat --help or the local manual if the example is rejected.

Find creation dates across a directory

GNU find can print birth times while walking a directory tree. For example:

find /home/alex/documents -type f -printf '%B+ %p\n'

Here %B+ requests the birth time in a readable format, and %p prints the path. Files whose birth time is unknown have an empty time field, so the output can include lines that begin with a space before the path. The -type f option limits results to regular files; remove it if you also want directories or other kinds of filesystem objects.

You can sort known timestamps chronologically because this date format is arranged from year to smaller time units:

find . -type f -printf '%B+ %p\n' | sort

This is a convenient report, but it is not a perfect data format for every possible filename. A filename can contain a newline, which makes one result appear as multiple lines. For a careful script, choose a delimiter and parsing method that can safely handle unusual filenames, or process entries individually. Also remember that a blank birth time is not sortable as a meaningful date; filter or inspect those entries separately rather than treating them as the oldest or newest files.

GNU find also has birth-time formatting support in its -printf feature, but that does not make birth-time searching universally portable. If the installed find says a format directive is unsupported, check its version and documentation. A practical alternative is to use find to select paths and run stat on them, keeping in mind that quoting and unusual filenames require care in scripts.

Why a birth time may be missing

Linux does not guarantee that every filesystem stores or reports a creation timestamp. The answer depends on more than the command: the filesystem must record the information, the kernel must expose it, and the userspace tool must know how to request and display it. Support varies across filesystem types, filesystem versions, kernel versions, and system utilities.

Modern Linux provides the statx interface, which can return a birth-time field when the filesystem supports it. A program can ask for that field and check whether the kernel marked it as available. But having the interface in the kernel does not mean every mounted filesystem can supply the value. Older tools may also omit a timestamp that a newer tool can display, so updating a utility can help in some cases—but it cannot create historical information the filesystem never recorded.

Filesystems mounted from network shares, removable media, or compatibility layers can add further variation. A remote server may provide different metadata from a local disk, and a mounted filesystem may map timestamps in its own way. If a date matters for an investigation or audit, record which machine, mount, and tool produced it rather than assuming every system will report the same result.

Creation time is not ctime or mtime

A common mistake is to use ctime as a shortcut for creation time. In Linux, ctime is the time an inode’s status was last changed. Changes to permissions, ownership, link count, or other metadata can update it; modifying file contents can also update it. It is not a stored “created on” date, and it can be much later than the file’s original creation.

The modification time, or mtime, records when file contents were last modified according to the filesystem. It is useful for questions such as “which files changed recently?” but does not establish when the file was first created. Applications and archive tools can also preserve or set modification times, so even an old mtime does not prove that the current filesystem object is old.

The access time, or atime, concerns when file contents were last accessed, though mount options and system behavior can limit how often it is updated. These timestamps answer different questions:

  • Birth time: When this filesystem object was created, if that value is available.
  • mtime: When the contents were last modified.
  • ctime: When the inode’s status last changed.
  • atime: When the contents were last accessed, subject to filesystem and mount behavior.

Similarly, find -ctime searches by the age of the status-change timestamp; it does not search by creation date. The name is easy to misread, so use it only when a recent inode-status change is actually what you want.

What to do when stat reports no date

If stat returns - for %w, first confirm that you are using a Linux-compatible GNU stat and inspect the filesystem type and mount. A newer userspace tool may expose information that an old one did not, but if the filesystem never recorded the birth time, no command can calculate the original value exactly from mtime or ctime.

For an ext-family filesystem, an administrator may be able to inspect filesystem-specific metadata with tools such as debugfs. This is not a general solution: it applies only to particular filesystem formats, requires knowing the correct device and inode, and the relevant metadata may still be unavailable. Filesystem inspection tools can be risky when used against a mounted, changing filesystem, so consult their documentation and avoid experiments on important data.

When the timestamp is absent, look for independent records that answer the practical question instead. Possibilities include dated backups, version-control history, application logs, package-manager records, cloud synchronization history, or an original archive. Those sources may establish when a copy or version existed, but they do not magically recover a missing filesystem birth time. State what evidence you used and distinguish a documented estimate from a timestamp actually reported by the filesystem.

Choosing the right method for the job

For a quick check of one path, GNU stat -c '%w' -- file is the clearest option because its output is easy to interpret. Use %W if a script needs an epoch value, while explicitly handling zero as “unknown.” For a directory inventory, GNU find -printf '%B+ %p\n' avoids launching a separate process for each file and makes it easy to combine traversal with type or path filters.

For example, to list regular files under the current directory and include hidden files as well, use:

find . -type f -printf '%B+ %p\n'

Unlike shell wildcards, find . naturally descends into hidden directories. If you only need files whose contents changed during the last week, however, use an mtime-based test instead of seeking birth time. The right timestamp follows the question: creation of this filesystem object, last content change, or last metadata change are not interchangeable goals.

For portable scripts that may run on different Linux distributions, test the exact utility versions and filesystems in the target environment. Treat missing values as a normal result, not an exceptional date. If the date is evidence for a legal, security, or compliance decision, preserve the original file and relevant metadata, document the command and environment, and corroborate the timestamp with other records.

Related

Frequently Asked Questions

How do I find the creation date of a file in Linux?
Try stat -c '%w' -- filename with GNU stat. A date is returned when the filesystem exposes a birth time; - means it is unavailable.

Does Linux always store a file creation date?
No. Support depends on the filesystem and the kernel and tools used to read it. Even a current Linux system may have files with no reportable birth time.

Is ctime the same as creation time?
No. ctime records the last change to inode status, such as a permissions or ownership change. Use a reported birth time for creation, when available.

Can find search by creation date?
GNU find can print birth time with -printf '%B+ %p\n'. Availability and filtering capabilities vary by version and filesystem; ordinary -ctime is not a creation-time test.

Can I recover a missing creation date?
Not reliably from the standard timestamps alone. Backups, logs, version control, or filesystem-specific metadata may provide clues, but they are separate evidence and may not reveal the original birth time.

Linux Find File Creation Date: What Actually Works
Scroll to top