File creation time in Linux : How to get ??

Linux does not have file creation time history until EXT3. In EXT4 this extra feature is there.

First get the inode for the file for which you want to get creation time.

# ls -i file_name

135528  //inode for this file

#debugfs -R 'stat <135528>' /dev/sda1

crtime 0x3f1cacc966104fc -- Tue May 27 16:35:28 2012

>> Now you could see the file creation time.

Linux or any Unix flavors, there are 3 time stamps:

1. atime : The last time file was opened or executed
2. ctime : The time the inode information was updated (chmod, chown etc does that). ctime also gets updated when file is modified
3. mtime: The time file was closed after it was opened for write

Command to see atime # ls -lu
Command to see ctime # ls -lc
Command to see mtime # ls -l

in EXT 4 - crtime will give creation time stamp.

you can use stat command to get the above 3 time stamps.(atime, mtime , ctime)

# stat myfile

 File: `myfile'
 Size: 41              Blocks: 8          IO Block: 4096   regular file
Device: fd04h/64772d    Inode: 655406      Links: 1
Access: (0777/-rwxrwxrwx)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2012-07-30 13:06:26.000000000 +0100
Modify: 2012-07-30 13:06:26.000000000 +0100
Change: 2012-07-30 13:06:46.000000000 +0100

Post a Comment