红联Linux门户
Linux帮助

Linux命令之stat-显示文件或文件系统状态

发布时间:2015-02-05 10:29:11来源:linux网站作者:codingstandards

用途说明
stat命令可以用来显示文件或文件系统状态信息(display file or file system status),它显示的信息比ls -l命令显示出来的更多些。

常用方式
格式:stat <file>

显示指定文件<file>的状态信息。

格式:stat -f <file>

显示<file>所在文件系统的状态信息。

格式:stat -t <file>

以简明格式显示<file>的状态信息。


使用示例
示例一
[root@www ~]# ls -l myfile
-rw-r--r-- 1 root root 0 2010-10-09 myfile

[root@www ~]# stat myfile
File: “myfile”
Size: 0               Blocks: 8          IO Block: 4096   一般空文件
Device: fd00h/64768d    Inode: 194805815   Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2010-12-12 12:22:35.000000000 +0800
Modify: 2010-10-09 20:44:21.000000000 +0800
Change: 2010-10-09 20:44:21.000000000 +0800
[root@www ~]# stat -f myfile
File: "myfile"
ID: 0        Namelen: 255     Type: ext2/ext3
Block size: 4096       Fundamental block size: 4096
Blocks: Total: 241555461  Free: 232910771  Available: 220442547
Inodes: Total: 249364480  Free: 249139691
[root@www ~]# stat -t myfile
myfile 0 8 81a4 0 0 fd00 194805815 1 0 0 1292127755 1286628261 1286628261 4096
[root@www ~]#

示例二
[root@www ~]# ls -l unknown
ls: unknown: 没有那个文件或目录
[root@www ~]# stat unknown
stat: 无法 stat “unknown”: 没有那个文件或目录
[root@www ~]#