View File metadata through stat in CentOS
In CentOS, you can use stat to view the object metadata.
[Baby @ xiaoxiao abc] $ stat honey
File: 'honge'
Size: 25 Blocks: 8 IO Block: 4096 regular file
Device: 806 h/2054d Inode: 131076 Links: 1
Access: (0664/-rw-r --) Uid: (500/baby) Gid: (500/baby)
Access: 10:27:51. 851234105 + 0800
Modify: 10:44:58. 144226717 + 0800
Change: 10:44:58. 146226803 + 0800
Access: Last Access time
Modify: last modification time
Change: Status Change Time (maintained by the system and cannot be modified at Will)
Touch-a: Only update Access time (Change to current time)
Touch-m: Only update Modify time (Change to current time)
Touch-c: do not create a new file
Touch-t: Use the specified time to update the timestamp (only Change Access time and Modify time, and Change time to current time)
Example: touch-t [[CC] YY] MMDDhhmm [. ss] filename
[Root @ xiaoxiao cde] # touch-t 199906121808 honey
[Root @ xiaoxiao cde] # stat honey
File: 'honge'
Size: 25 Blocks: 8 IO Block: 4096 regular file
Device: 806 h/2054d Inode: 131076 Links: 1
Access: (0664/-rw-r --) Uid: (500/baby) Gid: (500/baby)
Access: 18:08:00. 000000000 + 0800
Modify: 18:08:00. 000000000 + 0800
Change: 13:31:40. 064221158 + 0800
When any file data changes (including the file data and metadata), Change will update, rename the file (mv), move (mv), or copy (cp-), the system updates the Change time of the file. When the file content is modified, Modify and Change are updated at the same time. After the Change time is updated, the system updates the Access time (only the Access time is updated) When the file is accessed for the first time. The Access time is not updated when the file is accessed.
[Baby @ xiaoxiao cde] $ touch honey
[Baby @ xiaoxiao cde] $ stat honey
File: 'honge'
Size: 25 Blocks: 8 IO Block: 4096 regular file
Device: 806 h/2054d Inode: 131076 Links: 1
Access: (0664/-rw-r --) Uid: (500/baby) Gid: (500/baby)
Access: 11:24:47. 041225726 + 0800
Modify: 11:24:47. 041225726 + 0800
Change: 11:24:47. 041225726 + 0800
[Baby @ xiaoxiao cde] $ cat honey &>/dev/null
[Baby @ xiaoxiao cde] $ stat honey
File: 'honge'
Size: 25 Blocks: 8 IO Block: 4096 regular file
Device: 806 h/2054d Inode: 131076 Links: 1
Access: (0664/-rw-r --) Uid: (500/baby) Gid: (500/baby)
Access: 11:25:16. 401228081 + 0800
Modify: 11:24:47. 041225726 + 0800
Change: 11:24:47. 041225726 + 0800
The Access time is updated for the first Access after the timestamp is updated with touch. The following figure shows the metadata after the second Access. The Access time is not updated.
[Baby @ xiaoxiao cde] $ cat honey &>/dev/null
[Baby @ xiaoxiao cde] $ stat honey
File: 'honge'
Size: 25 Blocks: 8 IO Block: 4096 regular file
Device: 806 h/2054d Inode: 131076 Links: 1
Access: (0664/-rw-r --) Uid: (500/baby) Gid: (500/baby)
Access: 11:25:16. 401228081 + 0800
Modify: 11:24:47. 041225726 + 0800
Change: 11:24:47. 041225726 + 0800
Tar or various compression commands will update the Change time of the file when extracted. If you do not want to Change the Change time backup file, you can use the dd command (when the dd Command copies a single file, the timestamp is updated. All attributes of the file are retained when the entire partition is backed up. The process is as follows:
Create a new partition sda10 and mount it to/media/sda10 without formatting.
[Root @ xiaoxiao cde] # ll/dev/sda10
Brw-rw ---- 1 root disk 8, 10 Mar 30 12:58/dev/sda10
[Root @ xiaoxiao abc] # dd if =/dev/sda6 of =/dev/sda10 & (/dev/sda6 mounted under/tmp)
[1] 5917
[Root @ xiaoxiao abc] # mount/dev/sda10/media/sda10/
[Root @ xiaoxiao cde] # stat/media/sda10/cde/honey/tmp/cde/honey
File: '/media/sda10/cde/honey'
Size: 25 Blocks: 8 IO Block: 4096 regular file
Device: 80ah/2058d Inode: 131076 Links: 1
Access: (0664/-rw-r --) Uid: (500/baby) Gid: (500/baby)
Access: 11:25:16. 401228081 + 0800
Modify: 11:24:47. 041225726 + 0800
Change: 11:24:47. 041225726 + 0800
File: '/tmp/cde/honey'
Size: 25 Blocks: 8 IO Block: 4096 regular file
Device: 806 h/2054d Inode: 131076 Links: 1
Access: (0664/-rw-r --) Uid: (500/baby) Gid: (500/baby)
Access: 11:25:16. 401228081 + 0800
Modify: 11:24:47. 041225726 + 0800
Change: 11:24:47. 041225726 + 0800
The metadata of the two files is identical.