Linux Commands - Display file atime ctime mtime using the stat command
by
Jeremy Canfield |
Updated: February 11 2024
| Linux Commands articles
The stat command can be used to display the time a file was last accessed (atime), last modified (mtime) and last changed (ctime).
~]# stat /tmp/foo.txt
File: /tmp/foo.txt
Size: 7940168 Blocks: 15520 IO Block: 4096 regular file
Device: fd04h/64772d Inode: 105729 Links: 1
Access: (0664/-rw-rw-r--) Uid: ( 409/ john.doe) Gid: ( 2001/admins)
Context: system_u:object_r:usr_t:s0
Access: 2020-03-31 22:44:47.895474745 -0500
Modify: 2020-03-31 22:43:17.434452999 -0500
Change: 2020-03-31 22:43:17.434452999 -0500
Birth: -
Or, the --format option can be used to display just the last accessed time (atime).
- %x = human readable
- %X = seconds since epoch
stat --format %x /tmp/foo.txt
Or just the last modified time (mtime).
- %y = human readable
- %Y = seconds since epoch
stat --format %y /tmp/foo.txt
Or just the last changed time (ctime).
- %z = human readable
- %Z = seconds since epoch
stat --format %z /tmp/foo.txt
Did you find this article helpful?
If so, consider buying me a coffee over at