简介
在linux系统中,文件的数据分为数据和元数据,元数据可以通过stat命令查看。
stat
stat命令显示:- File:文件名
- Size:文件大小
- Blcoks:文件占用blocks数量
- IO Blcock:文件系统的单个blcock大小
- regular file:文件类型
- Inode:inode号码
- Links:硬链接数量
- Access:文件权限
- Uid:文件属主
- Gid:文件的属组
- Context :selinux权限
- Access:文件的访问时间
- Modify:文件的修改时间(内容修改)
- Change:文件的修改时间(包含元数据修改)
touch
在linux中,touch命令可以修改文件的时间戳
- a:修改访问时间
- m:修改文件的修改时间
- -t :STAMP
修改文件访问时间
[root@localhost ~]# stat /etc/issue
File: ‘/etc/issue’
Size: 23 Blocks: 8 IO Block: 4096 regular file
Device: fd00h/64768d Inode: 67148200 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Context: system_u:object_r:etc_t:s0
Access: 2019-11-10 15:58:05.352305843 -0500
Modify: 2017-08-30 11:53:07.000000000 -0400
Change: 2019-11-10 15:58:05.352305843 -0500
[root@localhost ~]# touch -at "201811101256.58" /etc/issue
[root@localhost ~]# !stat
stat /etc/issue
File: ‘/etc/issue’
Size: 23 Blocks: 8 IO Block: 4096 regular file
Device: fd00h/64768d Inode: 67148200 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Context: system_u:object_r:etc_t:s0
Access: 2018-11-10 12:56:58.000000000 -0500
Modify: 2017-08-30 11:53:07.000000000 -0400
Change: 2019-11-10 16:00:42.174309377 -0500
Birth: -
修改修改时间
[root@localhost ~]# touch -at "201811101256.58" /etc/issue
[root@localhost ~]# !stat
stat /etc/issue
File: ‘/etc/issue’
Size: 23 Blocks: 8 IO Block: 4096 regular file
Device: fd00h/64768d Inode: 67148200 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Context: system_u:object_r:etc_t:s0
Access: 2018-11-10 12:56:58.000000000 -0500
Modify: 2017-08-30 11:53:07.000000000 -0400
Change: 2019-11-10 16:00:42.174309377 -0500
Birth: -
[root@localhost ~]# touch -mt "201501011011.12" /etc/issue
[root@localhost ~]# !stat
stat /etc/issue
File: ‘/etc/issue’
Size: 23 Blocks: 8 IO Block: 4096 regular file
Device: fd00h/64768d Inode: 67148200 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Context: system_u:object_r:etc_t:s0
Access: 2018-11-10 12:56:58.000000000 -0500
Modify: 2015-01-01 10:11:12.000000000 -0500
Change: 2019-11-10 16:04:32.081314558 -0500
Birth: -