$stat <file name> command basically displays file or file-system status. stat command is used to find Access , Modify, Change date and time for any file or directory in Unix like operating systems. e.g
$stat /root/install.log File: `/root/install.log' Size: 17154 Blocks: 48 IO Block: 4096 regular file Device: fd00h/64768d Inode: 1177346 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2011-09-30 16:24:39.000000000 +0100 Modify: 2011-09-30 16:28:59.000000000 +0100 Change: 2011-09-30 16:29:04.000000000 +0100
As show in above example, It also displays owner and group associated with particular file. permissions on particular file. etc
There is no creation date available as far as I know unless you log the file creation date in a script. You can use the stat command as mentioned above to get the time stamp for last access, last change and last modification time.
$stat --version stat (GNU coreutils) 5.97 Copyright (C) 2006 Free Software Foundation, Inc. This is free software. You may redistribute copies of it under the terms of the GNU General Public License <http://www.gnu.org/licenses/gpl.html>. There is NO WARRANTY, to the extent permitted by law. Written by Michael Meskes.
In linux, centos, fedora, redhat, suse, ubuntu, mint, debian, mandrake, caldera, yolinux, gnulinux
How to find directory last change / modification date and time?
How to find file / filesystem last change / modification date and time?
How to find last “access” date and time for file / directory?
As we are talking about time stamp (access, change, modify) for files / directories in linux, we much consider talking about “touch” command.
“touch” [options] <file name(s)> :
Mainly touch command is used to change time stamp for files. If file does not exist then touch command creates file with current time stamp. e.g
$touch file1 file2 file3
will create 3 files in your present working directory with current time stamp.
Several of touch’s options are specifically designed to allow the user to change the timestamps for files. For example, the -a option changes only the access time, while the -m option changes only the modification time. The use of both of these options together changes both the access and modification times to the current time, for example:
$touch -am file11
The -r (i.e., reference) option followed directly by a space and then by a file name tells touch to use that file’s time stamps instead of current time. For example, the following would tell it to use the times of file4 for file5:
$touch -r myfile yourfile
The -B option modifies the timestamps by going back the specified number of seconds, and the -F option modifies the time by going forward the specified number of seconds. For example, the following command would make file7 30 seconds older than file6.
$touch -r myfile -B 30 yourfile
Importance of touch command.
Ah, beware before you use touch command on production system.
How to change times tamp using touch command?
ls -U will list the folders creation date