$linuxjunkies
>

stat(1)

Display detailed file and filesystem information including permissions, ownership, timestamps, and inode data.

UbuntuDebianFedoraArch

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

FlagWhat it does
-c FORMATUse custom output format string (e.g., '%a %U:%G %s' for mode, owner, size)
-fDisplay filesystem statistics instead of file statistics
-LFollow symbolic links; show stats for target file, not symlink itself
-lUse long format (terse, one stat per line for scripting)
-tPrint in terse format, single line per file
--printf=FORMATPrintf-style format string (allows \n, \t escape sequences)
-wFollow symlinks (same as -L)
--cached=MODESet caching mode for stat syscall (always, never, positive)

Examples

Show detailed metadata for /etc/passwd including inode, permissions, size, and all timestamps

stat /etc/passwd

Show permissions, owner:group, size, and filename in one line (permissions mode, user, group, size, name)

stat -c '%A %U:%G %s %n' /etc/passwd

Display filesystem statistics for the /home mount point (block size, total blocks, inodes)

stat -f /home

Follow the symlink and show stats for the actual python3 binary, not the link itself

stat -L /usr/bin/python3

Show only the last access time in ISO 8601 format

stat -c '%x' /var/log/syslog

List 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

Related commands