stat(1)
Display detailed file and filesystem information including permissions, ownership, timestamps, and inode data.
Synopsis
stat [OPTION]... FILE...Description
stat displays comprehensive metadata about files and filesystems. Unlike ls, it shows exact timestamps, inode numbers, block allocation, and permission bits in numeric form. Use it to debug file ownership issues, check access times, or examine filesystem behavior.
By default, stat shows file information in human-readable format. Use -c for custom output or -f to display filesystem statistics instead of file statistics.
Common options
| Flag | What it does |
|---|---|
-c FORMAT | Use custom output format string (e.g., '%a %U:%G %s' for mode, owner, size) |
-f | Display filesystem statistics instead of file statistics |
-L | Follow symbolic links; show stats for target file, not symlink itself |
-l | Use long format (terse, one stat per line for scripting) |
-t | Print in terse format, single line per file |
--printf=FORMAT | Printf-style format string (allows \n, \t escape sequences) |
-w | Follow symlinks (same as -L) |
--cached=MODE | Set caching mode for stat syscall (always, never, positive) |
Examples
Show detailed metadata for /etc/passwd including inode, permissions, size, and all timestamps
stat /etc/passwdShow permissions, owner:group, size, and filename in one line (permissions mode, user, group, size, name)
stat -c '%A %U:%G %s %n' /etc/passwdDisplay filesystem statistics for the /home mount point (block size, total blocks, inodes)
stat -f /homeFollow the symlink and show stats for the actual python3 binary, not the link itself
stat -L /usr/bin/python3Show only the last access time in ISO 8601 format
stat -c '%x' /var/log/syslogList each file with its inode number and octal permissions using printf-style formatting
stat --printf='%n: inode=%i mode=%a\n' *Extract modification time as Unix timestamp and convert to human-readable date
stat -c '%Y' /tmp/file.txt | xargs -I {} date -d @{} '+%Y-%m-%d'Display SELinux security context of the file (if available on system)
stat -c '%C' /home/user/file