Linux File time
GuideThe file time is the file access time, modification time, and change time. Atime is called the access time in the Linux file system. When the file content is accessed, the time is updated. mtime indicates that when "content data" is modified, the Linux system will update this time. ctime is the state time in the Linux system. When the State of the file is changed, the time will be changed.File time
I believe everyone is familiar with the windows operating system. When we create a file in windows, the system will also create relevant parameters for the file to describe the file,
These parameters include the file size, file type, location, and creation, modification, and access time. So let's see if there are similar parameters in Linux?
In Linux, we can use the stat + file name to view the relevant parameters of the file. The specific parameters are described as follows:
In a Linux File System, we found that apart from the file size, file name, and file time, we also added Inode and block information, which is mainly related to the composition of the Linux File System, in Linux, the next file has an Inode number. An Inode number corresponds to at least one block. bolck is the structure of the file content, and the number of file block blocks is related to the file size, in Linux, the block size is fixed. Today, we will mainly introduce the three time periods in Linux. They are
Access Time, Modify Time, and Change Time ).
AtimeAtime is short for Access Time. It is called Access Time in the Linux file system. When the file content is accessed, the Access Time is updated, for example, when we use commands such as cat, more, and less to view the file content, the file access time will be updated, such:
MtimeMtime is short for Modification Time. It indicates that when "content data" is modified, the Linux system will update the Time. For example, we use echo, vim and other commands write data to files
In the middle, when we use the echocommand to write a string to the test.txt file, we find that mtime and the ctime we will mention below have been changed. Let's go to the ctime below to see why such a result is generated!
CtimeCtime is the status time in the Linux system, that is, the State time. When the file state is changed, that is, the file property is changed, this time will be changed, for example, the links (number of links) in the file system ), size (file size), file permission, and blocks (number of file blocks). When these parameters are changed, Linux will change the time parameter corresponding to the file.
Now you may understand why the ctime of the file is changed when you modify the mtime of the file, because when the file content is modified, the file size, that is, the size, will change. Therefore, the file status will be updated as the file content is modified. Therefore, the mtime of the file is modified, and the ctime of the file is also changed.
Other methods for viewing file time1. ls-l +-time = xx time + file name;
By default, this query method displays the file's mtime.
2. ls-lx + file name
In this query method
C <--> ctime
U <--> atime
Ls-lc filename: list the ctime of the object (last modification time)
Ls-lu filename: list the atime of a file (last access time)
Ls-l filename: list the mtime of the object (last modification time)
SummaryThe time of the three files records the access, modification, and change time of the files in the Linux file system. When the files or programs in Linux have problems, we can query these times to determine when operations are performed, which affects these files.
From: http://geek.csdn.net/news/detail/130948
Address: http://www.linuxprobe.com/linux-file-time.html