您好,登錄后才能下訂單哦!
小編給大家分享一下CentOS中怎么通過stat查看文件的元數(shù)據(jù),相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!
CentOS中可以通過stat查看文件的元數(shù)據(jù)
[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/-rw-rw-r--) Uid: ( 500/ baby) Gid: ( 500/ baby)
Access: 2015-03-30 10:27:51.851234105 +0800
Modify: 2015-03-30 10:44:58.144226717 +0800
Change: 2015-03-30 10:44:58.146226803 +0800
Access:最后訪問時(shí)間
Modify:最后修改時(shí)間
Change:狀態(tài)更改時(shí)間(由系統(tǒng)維護(hù),無法隨意修改)
touch -a :僅更新Access time(同時(shí)更新Change為current time)
touch -m:僅更新Modify time(同時(shí)更新Change為current time)
touch -c:不創(chuàng)建新文件
touch -t:使用指定的時(shí)間更新時(shí)間戳(僅更改Access time與Modify time,Change time更新為current time)
例: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/-rw-rw-r--) Uid: ( 500/ baby) Gid: ( 500/ baby)
Access: 1999-06-12 18:08:00.000000000 +0800
Modify: 1999-06-12 18:08:00.000000000 +0800
Change: 2015-03-30 13:31:40.064221158 +0800
當(dāng)文件的任何數(shù)據(jù)改變時(shí)(包括文件的數(shù)據(jù)和元數(shù)據(jù)),Change會更新,對文件重命名(mv),移動(mv)或者復(fù)制時(shí)(cp -a),系統(tǒng)都會更新文件的Change time。當(dāng)文件的內(nèi)容被修改時(shí)Modify和Change會同時(shí)更新。當(dāng)Change time更新后,第一次訪問該文件,系統(tǒng)會更新Access time(僅更新Access time),之后對該文件的訪問,將不會更新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/-rw-rw-r--) Uid: ( 500/ baby) Gid: ( 500/ baby)
Access: 2015-03-30 11:24:47.041225726 +0800
Modify: 2015-03-30 11:24:47.041225726 +0800
Change: 2015-03-30 11:24: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/-rw-rw-r--) Uid: ( 500/ baby) Gid: ( 500/ baby)
Access: 2015-03-30 11:25:16.401228081 +0800
Modify: 2015-03-30 11:24:47.041225726 +0800
Change: 2015-03-30 11:24:47.041225726 +0800
用touch更新時(shí)間戳后的第一次訪問,Access time更新了,下面是第二次訪問之后的元數(shù)據(jù),Access time并沒有更新。
[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/-rw-rw-r--) Uid: ( 500/ baby) Gid: ( 500/ baby)
Access: 2015-03-30 11:25:16.401228081 +0800
Modify: 2015-03-30 11:24:47.041225726 +0800
Change: 2015-03-30 11:24:47.041225726 +0800
tar或者各種壓縮命令在解壓出來時(shí)都會更新文件的Change time,若想要不更改Change time備份文件可以使用dd命令(dd命令在復(fù)制單個(gè)文件時(shí),會更新時(shí)間戳,在備份整個(gè)分區(qū)時(shí),會保留文件的所有屬性),過程如下:
新建一個(gè)分區(qū)sda10,不用格式化,掛載到/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掛載在/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-rw-r--) Uid: ( 500/ baby) Gid: ( 500/ baby)
Access: 2015-03-30 11:25:16.401228081 +0800
Modify: 2015-03-30 11:24:47.041225726 +0800
Change: 2015-03-30 11:24: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/-rw-rw-r--) Uid: ( 500/ baby) Gid: ( 500/ baby)
Access: 2015-03-30 11:25:16.401228081 +0800
Modify: 2015-03-30 11:24:47.041225726 +0800
Change: 2015-03-30 11:24:47.041225726 +0800
兩個(gè)文件的元數(shù)據(jù)一模一樣。
以上是“CentOS中怎么通過stat查看文件的元數(shù)據(jù)”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對大家有所幫助,如果還想學(xué)習(xí)更多知識,歡迎關(guān)注億速云行業(yè)資訊頻道!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。