linux文件时间有三类:
atime (Access time)读取文件或者执行文件时更改的时间
mtime(Modified time)写入文件时随文件内容的更改而更改的时间
ctime (Create time)写入文件、更改所有者、权限或链接设置时随 Inode 的内容更改而更改的。随mtime改变而改变。
那么每回ls -l显示的时间是什么时间哪?
我们使用stat来看看这些时间们:
e.g
[root@monitor test]# stat a
File: `a'
Size: 136 Blocks: 8 IO Block: 4096 regular file
Device: fd00h/64768d Inode: 3074500 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2011-03-23 13:36:07.000000000 +0800
Modify: 2011-03-23 13:32:55.000000000 +0800
Change: 2011-03-23 13:32:55.000000000 +0800
[root@monitor test]# ll a
-rw-r--r-- 1 root root 136 Mar 23 13:32 a
我们再做一下以下的操作
[root@monitor test]# chown -R mj.mj a
[root@monitor test]# stat a
File: `a'
Size: 136 Blocks: 8 IO Block: 4096 regular file
Device: fd00h/64768d Inode: 3074500 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 502/ mj) Gid: ( 503/ mj)
Access: 2011-03-23 13:36:07.000000000 +0800
Modify: 2011-03-23 13:32:55.000000000 +0800
Change: 2011-03-24 10:40:18.000000000 +0800
[root@monitor test]# ll a
-rw-r--r-- 1 mj mj 136 Mar 23 13:32 a
可以清晰的看出ll出来的时间是什么时间。
然后再进行一个操作
[root@monitor test]# touch a
[root@monitor test]# stat a
File: `a'
Size: 136 Blocks: 8 IO Block: 4096 regular file
Device: fd00h/64768d Inode: 3074500 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 502/ mj) Gid: ( 503/ mj)
Access: 2011-03-24 10:51:35.000000000 +0800
Modify: 2011-03-24 10:51:35.000000000 +0800
Change: 2011-03-24 10:51:35.000000000 +0800
ls -lc filename 列出文件的 ctime
ls -lu filename 列出文件的 atime
ls -l filename 列出文件的 mtime
那这个三个time有什么用?答曰:该用的时候,就会有大用处!!!
转载于:https://blog.51cto.com/yjw1983/524968