When you talk to skilled Unix users, you often hear them arrogant about the term "Change
Time) "and" modification time )". For many (and many dictionaries), changes and modifications are the same. What is the difference here?
The difference between changing and modifying is that you can change the label of a component or its content. If someone says chmod A-W myfile, this is a change; if someone says echo Foo> myfile, then
This is a change. The change is because the index node of the file has changed, and the modification is because the content of the text has changed. [The file modification time is also called the timestamp.]
As long as we discuss the change time and modification time, we cannot mention the "Access time". The access time is the last time the file was read. Therefore, reading a file updates the access time of the file. When the change time does not change (the information about the file is not changed ), the same is true for its modification time (the file itself has not been changed)
Sometimes, in many cases, changing the time or "ctime" is mistakenly written as "creation time", including some UNIX reference manuals. Don't trust them. Here's what I got from Man. It's for your reference only!
St_atime
Time when file data was last accessed. changed by
Following functions: creat (), mknod (), pipe (),
Utime (2), and read (2 ).
St_mtime
Time when data was last modified. changed by the fol-
Lowing functions: creat (), mknod (), pipe (), utime (),
And write (2 ).
St_ctime
Time when File status was last changed. changed by
Following functions: chmod (), chown (), creat (),
Link (2), mknod (), pipe (), unlink (2), utime (), and
Write ().
The time displayed by LS is mtime.
After touch, the file time should change. You can try it.
Problem description
What is the difference between the ctime, mtime, and atime of a file?
Configuration Information
Solution
The access time of the file. atime is changed when the file is read or executed.
The modified time and mtime of the file are changed as the file content changes when the file is written.
File create time, ctime is changed when the file is written, the owner, permission, or link settings are changed with the inode content.
Therefore, changing the file content changes the mtime and ctime, but the ctime of the file may be changed when the mtime is not changed-when the permission is changed, but the file content remains unchanged.
The LS (1) command can be used to list the atime, ctime, and mtime of a file.
Ls-LC filename: list the ctime of a file
Ls-lu filename: list the atime of a file
Ls-l filename: list the mtime of a file
Atime may not be modified after the file is accessed, because if the noatime parameter is used during the Mount operation when the ext3 file system is used, the atime information will not be updated. This is canceled with noatime. It does not mean the real situation is canceled. all three time stamps are stored in inode. if mtime and atime are modified, inode will be changed. Since inode is changed, the ctime will be changed. the reason why noatime is used in mount option is that you do not want to make too many modifications to file system to improve the efficiency of compaction.