≡ Menu

Check when was the file last accessed or modified in Linux

The question – I want to check when was a file on my Linux box last changed. I want the change date and time. Is there a Linux command to do this?

Yes, there is a command called stat which can be used to get several useful statistics on a file. The stat command outputs the last accessed time, the last modified time and the last change time of a file.

[root@server ~]# stat index.html
  File: `index.html'
  Size: 27925           Blocks: 56         IO Block: 4096   regular file
Device: 61h/97d Inode: 140314748   Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2013-10-03 11:09:17.000000000 +0400
Modify: 2013-10-03 11:09:18.000000000 +0400
Change: 2013-10-03 11:09:18.000000000 +0400
[root@server ~]#

The three times need some explanation to understand them – The above output shows that the file was last accessed on 3rd October, was modified on 3rd October. The change time is the time at which the file was last modified in the inode table.

In addition to outputting statistics on a file, the stat command can also be used to output statistics on a file system:

[root@server ~]# stat -f /
  File: "/"
    ID: 0        Namelen: 255     Type: ext2/ext3
Block size: 4096       Fundamental block size: 4096
Blocks: Total: 6553600    Free: 6277985    Available: 6277985
Inodes: Total: 13107200   Free: 13075540
[root@server ~]#

Comments on this entry are closed.