Tell me more ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Is there a command in linux to check all timestamps of a file?

I'm trying to see the Last modified, created, and touched dates on the file.

share|improve this question
2  
Just to point out, Linux files don't have birth dates. Thus, it's not possible to determine the date a file was created. – FatalError Feb 7 '12 at 15:12
noticed that =(. Thanks for pointing it out to me. – Mechaflash Feb 7 '12 at 15:25
1  
@FatalError: Various filesystems already support birth/creation timestamps; the real trouble is in accessing such extra information. (One can't just extend struct stat without breaking things, unfortunately...) You can try out debugfs -R "stat <1234>" /dev/sdXY for ext4, replacing 1234 with an ino. – grawity Feb 7 '12 at 17:03
@grawity: Neat! I always wondered why no fs had it... but I guess they do, but like you said, can't just go breaking the ABI for existing binaries. Thanks for the tip :). – FatalError Feb 7 '12 at 17:45

1 Answer

up vote 5 down vote accepted

The command is basically called stat.

charon:Desktop werner$ stat test
234881026 41570368 -rw-r--r-- 1 werner staff 0 0 "Feb  7 16:03:06 2012" "Feb  7 16:03:06 2012" "Feb  7 16:03:06 2012" "Feb  7 16:03:06 2012" 4096 0 0 test

If you want to adjust the format, refer to the manpages, since the output is OS-specific and varies under Linux/Unix.

Generally, you can get the times through a normal directory listing as well:

  • ls -l outputs last time the file content was modified, the mtime
  • ls -lc outputs last time of file status modification, the ctime (What's the difference?)
  • ls -lu outputs last access time (although the usefulness of this concept is subject to discussion)

And of course, ctime does not record when a file was "created". This is not possible in Unix (as @FatalError already stated in the comment above).

share|improve this answer
+1 Thank you so much =D. – Mechaflash Feb 7 '12 at 15:10

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.