Files & folders

Linux stat command

Display detailed metadata about a file or directory.

Availability: Common Linux commands; shell built-ins and external implementations may differ by distribution.中文

Syntax

stat [OPTION]... FILE...

Examples

Show detailed metadata for a file.

stat report.txt

Print permissions, owner, size and name.

stat -c '%A %U %s %n' report.txt

Parameters, options and clauses

Option / clauseDescription
-c, --format=FORMATPrint selected metadata using a format string.
-f, --file-systemShow filesystem status rather than file status.
-L, --dereferenceFollow symbolic links and report the target.
-t, --tersePrint information in a concise format.
--printf=FORMATFormat output without a trailing newline.
Safety note

Review a command and its target before running it. Commands that alter files, services, accounts, disks, permissions or databases may be difficult to reverse. Test in a safe environment and keep backups.

Official reference ↗Back to directory