Linux的stat命令

####创建文件
-sh-4.2$ vi temp.txt
-sh-4.2$ stat temp.txt
  File: ‘temp.txt’
  Size: 4               Blocks: 8          IO Block: 4096   regular file
Device: ca02h/51714d    Inode: 3736722     Links: 1
Access: (0600/-rw-------)  Uid: ( 1027/db2inst2)   Gid: ( 1003/db2iadm1)
Access: 2020-08-17 05:15:15.225755222 -0500
Modify: 2020-08-17 05:15:15.225755222 -0500
Change: 2020-08-17 05:15:15.225755222 -0500
 Birth: -
-sh-4.2$

####修改文件的权限
-sh-4.2$ ls -l temp.txt
-rw------- 1 db2inst2 db2iadm1 4 Aug 17 05:15 temp.txt
-sh-4.2$
-sh-4.2$ chmod 644 temp.txt
-sh-4.2$ stat temp.txt
  File: ‘temp.txt’
  Size: 4               Blocks: 8          IO Block: 4096   regular file
Device: ca02h/51714d    Inode: 3736722     Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1027/db2inst2)   Gid: ( 1003/db2iadm1)
Access: 2020-08-17 05:15:15.225755222 -0500
Modify: 2020-08-17 05:15:15.225755222 -0500
Change: 2020-08-17 05:16:04.056557741 -0500  < 这里被修改了>
 Birth: -
-sh-4.2$

####修改文件的内容
-sh-4.2$ vi temp.txt
-sh-4.2$
-sh-4.2$ stat temp.txt
  File: ‘temp.txt’
  Size: 8               Blocks: 8          IO Block: 4096   regular file
Device: ca02h/51714d    Inode: 3736722     Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1027/db2inst2)   Gid: ( 1003/db2iadm1)
Access: 2020-08-17 05:15:15.225755222 -0500
Modify: 2020-08-17 05:17:09.072294820 -0500 < 这里被修改了>
Change: 2020-08-17 05:17:09.074294812 -0500 < 这里被修改了>
 Birth: -


####查看文件的内容
-sh-4.2$ cat temp.txt
123
456
-sh-4.2$ stat temp.txt
  File: ‘temp.txt’
  Size: 8               Blocks: 8          IO Block: 4096   regular file
Device: ca02h/51714d    Inode: 3736722     Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1027/db2inst2)   Gid: ( 1003/db2iadm1)
Access: 2020-08-17 05:15:15.225755222 -0500 < 这里没有被修改,为什么那?查看了一下文件系统mount的参数,其中有noatime>
Modify: 2020-08-17 05:17:09.072294820 -0500
Change: 2020-08-17 05:17:09.074294812 -0500
 Birth: -
-sh-4.2$


mount文件系统在指定"noatime,nodiratime"的情况下
read文件的时候不会导致atime、mtime、ctime改变
write文件只会导致mtime和ctime更新,不会导致atime更新。


请使用浏览器的分享功能分享到微信等