How to Check File Access Time with stat

Quick Linux Tip #59:

Question: How do I check when a file was last read without changing that timestamp?

Try: stat -c '%n Access: %x Modify: %y Change: %z' /var/log/syslog

Info: stat with -c custom formatting lets you inspect a file's timestamps without reading its contents like cat would. The format specifiers %x show access time (atime), %y shows modification time (mtime), and %z shows change time (ctime).

Examples:

  • $ stat -c '%Y' file  # Show modification time as a Unix timestamp
  • $ find /home -atime +90  # Find files not accessed in 90+ days
  • $ mount -o noatime /dev/sda1 /mnt  # Disable access-time updates

Note: atime records file access, but modern Linux systems commonly use relatime, which reduces how often access times are updated. As a result, atime should not always be interpreted as the exact time of the most recent read. Use stat when you need to inspect timestamps without opening the file for reading.




LinuxTeck.com
linuxteck@ubuntu:~$ stat -c '%n | Access: %x' /var/log/syslog
/var/log/syslog | Access: 2026-08-22 09:34:12.123456789 +0000

linuxteck@ubuntu:~$ stat -c 'Size: %s, Inode: %i, Links: %h' /etc/passwd
Size: 2345, Inode: 524290, Links: 1

linuxteck@ubuntu:~$ find /var/log -atime -1 -type f
/var/log/syslog
/var/log/auth.log
/var/log/nginx/access.log
linuxteck@ubuntu:~$

PREVIOUS ARTICLE Quick Linux Tip #58 - How to Profile Memory Usage in a Bash Script
About John Britto

John Britto Founder & Chief-Editor @LinuxTeck. A Computer Geek and Linux Intellectual having more than 20+ years of experience in Linux and Open Source technologies.

View all posts by John Britto →

Leave a Reply

Your email address will not be published.