stat [OPTION]... FILE...
Display file or file system status 顯示文件的系統屬性相關
-
常用選項
-f:display file system status instead of file status 查看系統inode相關參數 -
查看文件的屬性
[xzt7566@centos7-test Downloads]$ stat hosts File: ‘hosts’ -> ‘/etc/hosts’ Size: 10 Blocks: 0 IO Block: 4096 symbolic link Device: fd00h/64768d Inode: 51753441 Links: 1 Access: (0777/lrwxrwxrwx) Uid: ( 1000/ xzt7566) Gid: ( 1000/ xzt7566) Context: unconfined_u:object_r:user_home_t:s0 Access: 2019-05-04 16:13:22.423273050 +0800 Modify: 2019-05-04 16:13:20.542088369 +0800 Change: 2019-05-04 16:13:20.543088467 +0800 Birth: - Linux中文件沒有創(chuàng)建時間的概念
access time,文件數據最近的一次訪問時間
modify time,文件數據改變的時間(data).mtime發(fā)生變化,ctime一定變化
change time,文件狀態(tài)變更的時間.及包含數據改變(mtime)以及metadata(權限,屬主,屬組...)

硬鏈接文件完全一致,其中一個更改,另外的完全同步.
軟鏈接文件,為兩個不同的文件.互不影響.
-
查看系統狀態(tài) 可配合df -i查詢
[xzt7566@centos7-test Downloads]$ ls hosts [xzt7566@centos7-test Downloads]$ stat -f hosts File: "hosts" ID: fd0000000000 Namelen: 255 Type: xfs Block size: 4096 Fundamental block size: 4096 Blocks: Total: 5632321 Free: 4487482 Available: 4487482 Inodes: Total: 11270144 Free: 11129711 [xzt7566@centos7-test Downloads]$ df -i Filesystem Inodes IUsed IFree IUse% Mounted on /dev/mapper/centos-root 11270144 140433 11129711 2% / devtmpfs 478462 376 478086 1% /dev tmpfs 482688 1 482687 1% /dev/shm tmpfs 482688 1428 481260 1% /run tmpfs 482688 16 482672 1% /sys/fs/cgroup /dev/sda1 524288 355 523933 1% /boot tmpfs 482688 17 482671 1% /run/user/1000 stat -c '%A %n' * 類似 ls 的效果
-
例:
- cat file,head file ... 后atime變化、其他不變
- cat >> file,echo "xxx" >> file ... 后 mtime 和 ctime 變化
- chmod 777 file,chown xxx file ...后ctime變化、其他不變
- vim file只要存檔,所有屬性均變化
- vim file不存檔離開,atime變化,其他不變