[转] stat命令输出结果中, Access,Modify,Change的含义
2015-08-31 10:59
489 查看
先建立一个空白文件a.txt
利用stat命令查看文件a.txt的各种属性
上述最后三行的含义如下:
Access : 文件最近一次被访问的时间
Modify:文件内容最近一次被修改的时间
Change: 文件属性最近一次被改变的时间
假如用cat命令将文件a.txt的内容输出到终端( 执行 cat a.txt), 那么只有a.txt的Access就被刷新了
假如我们把当前的时间追加到a.txt(执行 date >> a.txt) , 那么a.txt的Modify和Change都被刷新
假如我们把a.txt的权限改为777(执行 chmod 777 a.txt) , 那么只有a.txt的Change被刷新
假如我们用vi命令把文件a.txt打开, 然后保存退出,那么a.txt的Access,Modify和Change都被刷新
PS:我们可以使用命令touch更新a.txt的Access和Modify时间,比如:
touch -d 1999-01-01 a.txt // 将a.txt的Access和Modify时间改为1999-01-01
touch -a a.txt// 只将a.txt的Access时间改为当前系统时间
touch -m a.txt // 只将a.txt的Modify时间改为当前系统时间
当我们用ls -l a.txt看到的时间是Modify时间
PS: http://unix.stackexchange.com/questions/2464/timestamp-modification-time-and-created-time-of-a-file
There are 3 kind of "timestamps":
Access - the last time the file was read
Modify - the last time the file was modified (content has been modified)
Change - the last time meta data of the file was changed (e.g. permissions)
To display this information, you can use
Remember that this sort of information depends highly on the filesystem and mount options. For example if you mount a partition with the
A utility to change the timestamps would be
Thefieldst_atimeischangedbyfileaccesses,for example, by execve(2), mknod(2), pipe(2),
utime(2) and read(2) (of more than zero bytes).Other routines, like mmap(2), may or may notupdate
st_atime.
Thefield st_mtime is changed by file modifications, for example, by mknod(2), truncate(2), utime(2)
and write(2) (of more than zero bytes).Moreover, st_mtime of a directory is changed by the creation
ordeletionoffilesinthat directory.The st_mtime field is not changed for changes in owner,
group, hard link count, or mode.
The field st_ctime is changed by writing or by setting inode information (i.e.,owner,group,link
count, mode, etc.).
1 | [emduser@emd tmp]$ touch a.txt |
2 |
3 | [emduser@emd tmp]$ ls -al a.txt |
4 |
5 | -rw-rw-r-- 1 emduser emd 0 Dec 14 16:44 a.txt |
01 | [emduser@emd tmp]$stat a.txt |
02 |
03 | File: `a.txt' |
04 |
05 | Size: 0 Blocks: 0IO Block: 4096 regular empty file |
06 |
07 | Device: fd00h/64768dInode: 654176Links: 1 |
08 |
09 | Access: (0664/-rw-rw-r--)Uid: (501/ emduser) Gid: (506/ emd) |
10 |
11 | Access: 2011-12-14 16:44:23.000000000 +0800 |
12 |
13 | Modify: 2011-12-14 16:44:23.000000000 +0800 |
14 |
15 | Change: 2011-12-14 16:44:23.000000000 +0800 |
Access : 文件最近一次被访问的时间
Modify:文件内容最近一次被修改的时间
Change: 文件属性最近一次被改变的时间
假如用cat命令将文件a.txt的内容输出到终端( 执行 cat a.txt), 那么只有a.txt的Access就被刷新了
假如我们把当前的时间追加到a.txt(执行 date >> a.txt) , 那么a.txt的Modify和Change都被刷新
假如我们把a.txt的权限改为777(执行 chmod 777 a.txt) , 那么只有a.txt的Change被刷新
假如我们用vi命令把文件a.txt打开, 然后保存退出,那么a.txt的Access,Modify和Change都被刷新
PS:我们可以使用命令touch更新a.txt的Access和Modify时间,比如:
touch -d 1999-01-01 a.txt // 将a.txt的Access和Modify时间改为1999-01-01
touch -a a.txt// 只将a.txt的Access时间改为当前系统时间
touch -m a.txt // 只将a.txt的Modify时间改为当前系统时间
当我们用ls -l a.txt看到的时间是Modify时间
PS: http://unix.stackexchange.com/questions/2464/timestamp-modification-time-and-created-time-of-a-file
There are 3 kind of "timestamps":
Access - the last time the file was read
Modify - the last time the file was modified (content has been modified)
Change - the last time meta data of the file was changed (e.g. permissions)
To display this information, you can use
statwhich is part of the coreutils.
statwill show you also some more information like the device, inodes, links, etc.
Remember that this sort of information depends highly on the filesystem and mount options. For example if you mount a partition with the
noatimeoption, no access information will be written.
A utility to change the timestamps would be
touch. There are some arguments to decide which timestamp to change (e.g. -a for access time, -m for modification time, etc.) and to influence the parsing of a new given timestamp. See
man touchfor more details.
touchcan become handy in combination with
cp -u("copy only when the SOURCE file is newer than the destination file or when the destination file is missing") or for the creation of empty marker files.
Thefieldst_atimeischangedbyfileaccesses,for example, by execve(2), mknod(2), pipe(2),
utime(2) and read(2) (of more than zero bytes).Other routines, like mmap(2), may or may notupdate
st_atime.
Thefield st_mtime is changed by file modifications, for example, by mknod(2), truncate(2), utime(2)
and write(2) (of more than zero bytes).Moreover, st_mtime of a directory is changed by the creation
ordeletionoffilesinthat directory.The st_mtime field is not changed for changes in owner,
group, hard link count, or mode.
The field st_ctime is changed by writing or by setting inode information (i.e.,owner,group,link
count, mode, etc.).
相关文章推荐
- 手动更新本地nexus中central库的索引
- 常见错误之java.lang.IllegalStateException: The application’s PagerAdapter changed the adapter’s cont。。。
- Oracle基本操作介绍
- 移植 jq
- 生活常识(一) 一个手机号能泄露这么多信息?
- jQuery ajax - ajax() 方法
- 对几种常见设计模式的理解
- validate表单验证
- 史上最牛 Maven POM 标签详解
- 【Matlab学习笔记】(四)认识matlab的文件类型和简单练习
- 联想笔记本Z460中BIOS设置U盘启动教程
- MD5加密工具
- oracle数据库基本数据类型
- 全国城市数据库plist文件和sqlite文件和json文件
- MyBatis
- 15问答为专业测试人员揭开“精准测试”的面纱
- IOS学习笔记 ---- 15/08/30之前
- 第一次作业
- 安装ASP.net mvc3 Installation failed with error code: (0x80070643), "安装时发生严重错误 "
- 工具——SVN常用命令