简单的ctime,atime和mtime区别说明

青春须早为,岂能长少年。这篇文章主要讲述简单的ctime,atime和mtime区别说明相关的知识,希望能为你提供帮助。
【简单的ctime,atime和mtime区别说明】简单写写ctime,atime和mtime的区别。
有些教程写的比较复杂,其实简单的很:
atime 就是access time 访问就会改变,无论是cat还是more,只要访问过,就会变。不影响另外两个。
ctime 是change time ,主要是修改权限、所有者才会变,chmod +x ,就会单独修改此时间。不影响另外两个。
如下,修改权限+x后change time 发生变化,其他两个未变

an@an-Y7000:~$ stat 1File: 1 Size: 509Blocks: 8IO Block: 4096regular file Device: 810h/2064dInode: 2003Links: 1 Access: (0644/-rw-r--r--)Uid: ( 1000/an)Gid: ( 1000/an) Access: 2022-01-25 16:02:38.020978784 +0800 Modify: 2022-01-11 14:43:12.387342409 +0800 Change: 2022-01-11 14:43:12.387342409 +0800 Birth: - an@an-Y7000:~$ chmod +x 1 an@an-Y7000:~$ stat 1 File: 1 Size: 509Blocks: 8IO Block: 4096regular file Device: 810h/2064dInode: 2003Links: 1 Access: (0755/-rwxr-xr-x)Uid: ( 1000/an)Gid: ( 1000/an) Access: 2022-01-25 16:02:38.020978784 +0800 Modify: 2022-01-11 14:43:12.387342409 +0800 Change: 2022-01-25 16:02:46.030978913 +0800 Birth: -

mtime 是modify time,未修改过内容,就是创建时间,之后如修改过内容则此时间会变,如用的vim同时 会把atime,ctime 一起修改。
如下,修改一下文本内容,则3个时间一起改变:
an@an-Y7000:~$ stat t.py File: t.py Size: 98Blocks: 8IO Block: 4096regular file Device: 810h/2064dInode: 15026Links: 1 Access: (0755/-rwxr-xr-x)Uid: ( 1000/an)Gid: ( 1000/an) Access: 2022-01-01 14:44:59.063923653 +0800 Modify: 2021-11-01 16:14:43.816264464 +0800 Change: 2021-11-01 16:14:43.826264464 +0800 Birth: - an@an-Y7000:~$ vim t.py an@an-Y7000:~$ stat t.py File: t.py Size: 104Blocks: 8IO Block: 4096regular file Device: 810h/2064dInode: 8148Links: 1 Access: (0755/-rwxr-xr-x)Uid: ( 1000/an)Gid: ( 1000/an) Access: 2022-01-25 16:13:18.420989114 +0800 Modify: 2022-01-25 16:13:18.420989114 +0800 Change: 2022-01-25 16:13:18.430989114 +0800 Birth: -

如只是追加,则只会修改mtime和ctime ,不会修改access time.
an@an-Y7000:~$ stat test.py File: test.py Size: 1022Blocks: 8IO Block: 4096regular file Device: 810h/2064dInode: 218Links: 1 Access: (0755/-rwxr-xr-x)Uid: ( 1000/an)Gid: ( 1000/an) Access: 2022-01-01 10:15:36.678685565 +0800 Modify: 2021-10-02 19:52:35.890585412 +0800 Change: 2021-10-02 19:52:35.900585412 +0800 Birth: -

追加文本后,ctime 和mtime 发生改变,atime 未变化
an@an-Y7000:~$ echo "###TEST"> > test.py an@an-Y7000:~$ stat test.py File: test.py Size: 1030Blocks: 8IO Block: 4096regular file Device: 810h/2064dInode: 218Links: 1 Access: (0755/-rwxr-xr-x)Uid: ( 1000/an)Gid: ( 1000/an) Access: 2022-01-01 10:15:36.678685565 +0800 Modify: 2022-01-25 16:32:03.501007262 +0800 Change: 2022-01-25 16:32:03.501007262 +0800 Birth: -


    推荐阅读