← 返回命令列表

Linux command

stat 命令

文件

复制后可按需替换文件名、目录或参数。

常用示例

Display file status

stat [file]

Display in terse format

stat -t [file]

Display filesystem status

stat -f [file]

Custom format output

stat -c "%n: %s bytes" [file]

Show access time

stat -c "%x" [file]

Show modification time

stat -c "%y" [file]

Show permissions in octal

stat -c "%a" [file]

Show all info for multiple files

stat [file1] [file2] [file3]

Follow symbolic links

stat -L [symlink]

说明

stat displays detailed information about files or filesystems. It shows metadata including size, permissions, ownership, timestamps, inode number, and device information. The default output includes file name, size, blocks, device, inode, links, access permissions, ownership, and access/modify/change times. Custom format strings allow selecting specific fields. stat is useful for scripting when specific file attributes are needed, or for investigating file properties not shown by ls.

参数

-f, --file-system
Display filesystem status instead of file.
-L, --dereference
Follow symbolic links.
-t, --terse
Print terse output.
-c _format_, --format= _format_
Use custom format string.
--printf= _format_
Like --format, but interpret backslash escapes and no trailing newline.

FAQ

What is the stat command used for?

stat displays detailed information about files or filesystems. It shows metadata including size, permissions, ownership, timestamps, inode number, and device information. The default output includes file name, size, blocks, device, inode, links, access permissions, ownership, and access/modify/change times. Custom format strings allow selecting specific fields. stat is useful for scripting when specific file attributes are needed, or for investigating file properties not shown by ls.

How do I run a basic stat example?

Run `stat [file]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -f, --file-system do in stat?

Display filesystem status instead of file.