Linux – Get Last Modified Date of File in Linux

command linelinux

I'm new to Linux. I'm using the command-line. I'm trying to view the last modified date of a file. How do I do that in Linux from the Command Line?

Best Answer

As mentioned by @edvinas.me, stat tells you various information about the file including the last modified date.

At first, I was confused with Modify and Change, just to clarify, stat output lists:

  • Access shows the time of last data access (e.g. read).
  • Modify shows the time of last data modification.
  • Change shows the time the file status last changed.

For example:

~ $ touch foo
~ $ stat foo
File: ‘foo’
Size: 0             Blocks: 0          IO Block: 4096   regular empty file
Device: fc01h/64513d    Inode: 410397      Links: 1
Access: (0644/-rw-r--r--)  Uid: (80972/ etomort)   Gid: (18429/  eem_tw)
Access: 2015-09-21 12:06:11.343616258 +0200
Modify: 2015-09-21 12:06:11.343616258 +0200
Change: 2015-09-21 12:06:11.343616258 +0200
Birth: -

~ $ echo "Added bar to foo file" >> foo
~ $ stat foo
File: ‘foo’
Size: 42            Blocks: 8          IO Block: 4096   regular file
Device: fc01h/64513d    Inode: 410654      Links: 1
Access: (0644/-rw-r--r--)  Uid: (80972/ etomort)   Gid: (18429/  eem_tw)
Access: 2015-09-21 12:09:31.298712951 +0200
Modify: 2015-09-21 12:09:31.298712951 +0200
Change: 2015-09-21 12:09:31.302713093 +0200
Birth: -

~ $ chmod 444 foo
~ $ stat foo
File: ‘foo’
Size: 42            Blocks: 8          IO Block: 4096   regular file
Device: fc01h/64513d    Inode: 410654      Links: 1
Access: (0444/-r--r--r--)  Uid: (80972/ etomort)   Gid: (18429/  eem_tw)
Access: 2015-09-21 12:09:31.298712951 +0200
Modify: 2015-09-21 12:09:31.298712951 +0200
Change: 2015-09-21 12:10:16.040310543 +0200
Birth: -
Related Question