mtime, atime, ctime difference

mtime   ls -l   显示最近修改文件内容的时间
atime   ls -lu  显示最近访问文件的时间
ctime   ls -li  显示最近文件有所改变的状态,如文件修改,属性\属主改变,节点,链接变化等

Three files are created abc

echo "1" > a
echo "2" > b
echo "3" > c

Execute ls -l, ls -lu, ls -li operation, mtime, atime, ctime are the same

-rw-r--r--. 1 root root 2 Aug  7 09:50 a
-rw-r--r--. 1 root root 2 Aug  7 09:50 b
-rw-r--r--. 1 root root 2 Aug  7 09:50 c

Performing cat a, echo "b"> b Operation

cat a
echo "b" > b

# 因 b 的内容改变,mtime(最近修改文件内容的时间) 随之更改
ls -l
-rw-r--r--. 1 root root 2 Aug  7 09:50 a
-rw-r--r--. 1 root root 2 Aug  7 09:51 b
-rw-r--r--. 1 root root 2 Aug  7 09:50 c

# 因 执行了 cat a 操作,atime(显示最近访问文件的时间) 更改
ls -lu
-rw-r--r--. 1 root root 2 Aug  7 09:51 a
-rw-r--r--. 1 root root 2 Aug  7 09:50 b
-rw-r--r--. 1 root root 2 Aug  7 09:50 c

# 因 b 的内容改变,ctime(最近文件有所改变的状态) 随之更改
ls -li
4195057 -rw-r--r--. 1 root root 2 Aug  7 09:50 a
4418917 -rw-r--r--. 1 root root 2 Aug  7 09:51 b
4418918 -rw-r--r--. 1 root root 2 Aug  7 09:50 c

If you use scp to copy the file to another machine, mtime, atime, ctime will change the default case, if do not want to change, you can add -p option, after scp command

man scp
-p      Preserves modification times, access times, and modes from the original file.

Guess you like

Origin www.cnblogs.com/klvchen/p/11313302.html