Article Title: three major modifications to linux Files. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
Linux Files have three modification times, which many of my friends like to confuse and include me. These files are now listed for reference.
1) modification time (mtime, modification time): This time refers to the time when the file content is modified, not the modification of the file attribute. When the data content is modified, this time changes, by default, the ls-l command displays the following time:
2) status time (ctime, status time): When the status of a file changes, the time changes. For example, if the file's permissions and attributes are changed, the time changes.
3) access time (atime, access time): This time is changed when the file content is read. For example, you can use cat to read/etc/man. config, then the atime of the file will change.
For example:
# Ls-l -- full-time/etc/man. config mtime
-Rw-r -- 1 root 4522 18:47:54. 000000000 + 0800/etc/man. config
# Ls-l -- time = atime -- full-time/etc/man. config
-Rw-r -- 1 root 4522 2010-03-15 14:20:20. 000000000 + 0800/etc/man. config
# Ls-l -- time = ctime -- full-time/etc/man. config
-Rw-r -- 1 root 4522 16:21:55. 000000000 + 0800/etc/man. config
Bytes -----------------------------------------------------------------------------------
# Run cat/etc/man. config and check atime again. The time has been changed.
# Ls-l -- time = atime -- full-time/etc/man. config
-Rw-r -- 1 root 4522 2010-03-15 14:24:30. 000000000 + 0800/etc/man. config
Change file permissions: # chmod o-r/etc/man. config
View ctime, which has been changed.
# Ls-l -- time = ctime -- full-time/etc/man. config
-Rw-r ----- 1 root 4522 2010-03-15 14:28:34. 000000000 + 0800/etc/man. config
If you edit the file content, the mtime changes.
If you want to view the three time conditions of the file together, you can use the command stat to view it.
# Stat/etc/man. config
File: '/etc/man. config'
Size: 4522 Blocks: 24 IO Block: 4096 regular file
Device: 807 h/2055d Inode: 1049307 Links: 1
Access: (0640/-rw-r -----) Uid: (0/root) Gid: (0/root)
Access: 14:24:30. 000000000 + 0800
Modify: 18:47:54. 000000000 + 0800
Change: 14:28:34. 000000000 + 0800
The time is exactly the same as the above time.
The file time is very important, because if you misjudge the file time, it may cause some programs to fail to run normally. In case we find that the time of a file is the future time (this problem often occurs, the GMT time we mentioned during installation is that). How can we change the time to the current time? We only need a touch command.
Touch usage:
Touch [-actmd] File
Parameters:
-A: only modify access time
-C: only modify the time without creating a file
-T: followed by time. Format: [YYMMDDhhmm]
-M: only modify mtime
-D: Followed by a date, or -- date = "date or time"
For example, if the man. config date is adjusted to two days ago:
# Touch-d "2 days ago"/etc/man. config
The result atime and mtime will change, but ctime will not.
By using the touch command, you can easily modify the date and time of a file and create an empty file. However, note that, even if you copy a file and copy all the property pages, you cannot copy the ctime property.
Commonly used touch commands are:
1) Create an empty file
2) change the date of a file to the current date (mtime and atime)