Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to view the metadata of files through stat in CentOS

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

Editor to share with you how to view the metadata of files through stat in CentOS, I believe most people don't know much about it, so share this article for your reference. I hope you can learn a lot after reading this article. Let's learn about it together.

You can view the metadata of a file through stat in CentOS

[baby@xiaoxiao abc] $stat honey

File: `honey'

Size: 25 Blocks: 8 IO Block: 4096 regular file

Device: 806h/2054d Inode: 131076 Links: 1

Access: (0664 / baby) Gid: (500 / baby)

Access: 2015-03-30 10 2715 51.851234105 + 0800

Modify: 2015-03-30 10 purl 44purl 58.144226717 + 0800

Change: 2015-03-30 10 purl 44purl 58.146226803 + 0800

Access: last visit time

Modify: last modified time

Change: state change time (maintained by the system and cannot be modified at will)

Touch-a: update only Access time (also update Change to current time)

Touch-m: update only Modify time (also update Change to current time)

Touch-c: do not create new files

Touch-t: update the timestamp with the specified time (only change Access time and Modify time,Change time to update to current time)

Example: touch-t [[CC] YY] MMDDhhmm [.ss] filename

[root@xiaoxiao cde] # touch-t 199906121808 honey

[root@xiaoxiao cde] # stat honey

File: `honey'

Size: 25 Blocks: 8 IO Block: 4096 regular file

Device: 806h/2054d Inode: 131076 Links: 1

Access: (0664 / baby) Gid: (500 / baby)

Access: 1999-06-12 1815 0815 00.000000000 + 0800

Modify: 1999-06-12 1815 0815 00.000000000 + 0800

Change: 2015-03-30 13 purl 31purl 40.064221158 + 0800

When any data of the file changes (including the data and metadata of the file), the Change is updated, and the file's Change time is updated when the file is renamed (mv), moved (mv), or copied (cp-a). Modify and Change are updated at the same time when the contents of the file are modified. When Change time is updated and the file is accessed for the first time, the Access time will be updated (only Access time will be updated), and subsequent access to the file will not update Access time.

[baby@xiaoxiao cde] $touch honey

[baby@xiaoxiao cde] $stat honey

File: `honey'

Size: 25 Blocks: 8 IO Block: 4096 regular file

Device: 806h/2054d Inode: 131076 Links: 1

Access: (0664 / baby) Gid: (500 / baby)

Access: 2015-03-30 111purl 47.041225726 + 0800

Modify: 2015-03-30 111purl 47.041225726 + 0800

Change: 2015-03-30 111purl 47.041225726 + 0800

[baby@xiaoxiao cde] $cat honey & > / dev/null

[baby@xiaoxiao cde] $stat honey

File: `honey'

Size: 25 Blocks: 8 IO Block: 4096 regular file

Device: 806h/2054d Inode: 131076 Links: 1

Access: (0664 / baby) Gid: (500 / baby)

Access: 2015-03-30 11 purl 25purl 16.401228081 + 0800

Modify: 2015-03-30 111purl 47.041225726 + 0800

Change: 2015-03-30 111purl 47.041225726 + 0800

The first access after the timestamp is updated with touch, Access time is updated, the following is the metadata after the second access, and Access time is not updated.

[baby@xiaoxiao cde] $cat honey & > / dev/null

[baby@xiaoxiao cde] $stat honey

File: `honey'

Size: 25 Blocks: 8 IO Block: 4096 regular file

Device: 806h/2054d Inode: 131076 Links: 1

Access: (0664 / baby) Gid: (500 / baby)

Access: 2015-03-30 11 purl 25purl 16.401228081 + 0800

Modify: 2015-03-30 111purl 47.041225726 + 0800

Change: 2015-03-30 111purl 47.041225726 + 0800

Tar or various compression commands update the Change time of the file when it is unzipped. If you do not want to change the Change time backup file, you can use the dd command (the dd command updates the timestamp when copying a single file, and retains all attributes of the file when backing up the entire partition). The process is as follows:

Create a new partition sda10 without formatting and mount it to / media/sda10.

[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 is 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 / baby) Gid: (500 / baby)

Access: 2015-03-30 11 purl 25purl 16.401228081 + 0800

Modify: 2015-03-30 111purl 47.041225726 + 0800

Change: 2015-03-30 111purl 47.041225726 + 0800

File: `/ tmp/cde/honey'

Size: 25 Blocks: 8 IO Block: 4096 regular file

Device: 806h/2054d Inode: 131076 Links: 1

Access: (0664 / baby) Gid: (500 / baby)

Access: 2015-03-30 11 purl 25purl 16.401228081 + 0800

Modify: 2015-03-30 111purl 47.041225726 + 0800

Change: 2015-03-30 111purl 47.041225726 + 0800

The metadata of the two files is exactly the same.

The above is all the contents of the article "how to view the metadata of files through stat in CentOS". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report