LinuxEye - Linux系统教程

LinuxEye - Linux系统教程

当前位置: 主页 > Linux教程 >

Linux time属性区别

时间:2012-07-15 09:58来源:未知 编辑:admin 点击:
Linux文件的change time和Modify time很多人很容易搞混淆,将ctime理解为create time(创建时间),那是瞎说的,Linux文件系统不会记录create time的,除非文件创建过后,没modify,没change,那么文件的
      Linux文件的change time和Modify time很多人很容易搞混淆,将ctime理解为create time(创建时间),那是瞎说的,Linux文件系统不会记录create time的,除非文件创建过后,没modify,没change,那么文件的创建时间和modify时间及change时间相同。
如:
[root@localhost ~]# stat lnmp.zip
  File: `lnmp.zip'
  Size: 66602649        Blocks: 130224     IO Block: 4096   regular file
Device: ca00h/51712d    Inode: 16528       Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2012-06-20 12:01:40.000000000 +0800
Modify: 2012-04-23 10:09:07.000000000 +0800
Change: 2012-06-20 12:01:40.000000000 +0800
access time是文档最后一次被读取的时间。因此阅读一个文档会更新它的access时间,但它的modify时间和change时间并没有变化。cat、more 、less、grep、sed、tail、head这些命令都会修改文件的access时间。
change time是文档的索引节点(inode)发生了改变(比如位置、用户属性、组属性等);
modify time是文本本身的内容发生了变化。[文档的modify时间也叫时间戳(timestamp).]

如:
st_atime      Time when file data was last accessed. Changed by the following functions:creat(), mknod(), pipe(),utime(2), and read(2).

st_mtime      Time when data was last modified. Changed by the following functions: reat(), mknod(), pipe(), utime(),and write(2).

st_ctime      Time when file status was last changed. time of last modification of file status information.Changed by the following functions: chmod(), chown(), creat(),link(2), mknod(), pipe(), unlink(2), utime(), and write().
chmod, chown,create,mv等动作会将Linux文件的change time修改为系统当前时间
ls命令看到的是modify time
用wget等工具下载的文件,cahnge time不会被修改。
用vi等工具编辑一个文件保存后,modify time会被修改。
用ls -l命令不会修改文件的access time,但cat命令会修改access time。

如:
ls -lu (show files access time and sort by name)
ls -lc (show files change time and sort by name )
ls -l (show files modify time and sort by name )
如果加上-t参数,则按相应的时间排序后显示。加上--time-style=long-iso,则会把文件的相应年月日时分秒time全部显示出来。
touch命令能改变文件的access时间和modify时间为任意指定的时间。
modify time只能改变为系统时间,不能改变为任意时间。甚至用c程序来直接读写inode,也不会修改change time。

转载请保留固定链接: https://linuxeye.com/Linux/713.html

------分隔线----------------------------
标签:time属性linux
栏目列表
推荐内容