Frequently Asked Question

What does stat tell me about a file?

stat prints everything the kernel knows about a file from its inode. You get the filename and size, the underlying device and inode number, the link count, the permission mode in both octal and rwx form, the owner and group, and four timestamps. Access (atime) is the last time the contents were read; Modify (mtime) is the last time the contents were changed; Change (ctime) is the last time the inode metadata changed (permissions, ownership, link count); Birth is the file's creation time on filesystems that support it.

The distinction between mtime and ctime catches a lot of people out. Changing a file's permissions updates ctime but not mtime; editing the contents updates both. atime is also expensive enough to track that many systems mount with relatime or noatime to skip frequent updates. For scripting, stat -c '%Y' file gives just the mtime as a Unix timestamp, which is the right way to compare ages without parsing human-readable output.

Further reading and video