← Full reference

stat

All file metadata — permissions, owner, size, inode, timestamps — in the format you need

stat shows file metadata from the inode: type, permissions, owner, size, link count, all timestamps. With -c it prints only the fields you need in a given format — more reliable than cutting columns out of ls -l. With -f it shows file system information. The sandbox has GNU coreutils 9.4.

Syntax

stat [options] file…
stat -c 'format' file…
stat -f [-c 'format'] path…

Exit code: 0 — all files found, 1 — at least one is missing.

Default output

  File: f
  Size: 6         	Blocks: 8          IO Block: 4096   regular file
Device: 0,64	Inode: 1134952     Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2026-10-13 15:21:52.594726010 +0000
Modify: 2026-10-13 15:21:52.594726010 +0000
Change: 2026-10-13 15:21:52.594726010 +0000
 Birth: 2026-10-13 15:21:52.594726010 +0000
FieldMeaning
Sizesize in bytes (for a symlink — the length of the target path)
Blockshow many 512-byte blocks are actually used on disk
IO Blockrecommended I/O block size
typeregular file, directory, symbolic link, fifo, socket, character special file…
Devicenumber of the device the file lives on
Inode / Linksinode number / number of hard links
Access: (0644/-rw-r--r--)permissions in octal and symbolic form
Uid / Gidnumeric ID and name of the owner / group
Access / Modify / Changeatime (read), mtime (content), ctime (metadata)
Birthcreation time (- if the FS doesn't store it)

Options

OptionWhat it does
-c 'format'print according to the format, with a newline at the end
--printf='format'the same, but no trailing newline, and \n, \t are understood
-Lfor a symbolic link, show the target's data, not the link's
-fdata about the file system the path lives on
-teverything on one line (terse machine format)

-c format: file

CodeWhat it printsExample
%nfile namef
%Nquoted name, for a link — with its target'l' -> 'f'
%apermissions in octal (%#a — with a leading zero)644, 4755
%Apermissions in symbolic form with the type-rw-r--r--
%f"raw" mode in hex81a4
%Ffile type in wordsregular file
%U / %uowner name / UIDroot / 0
%G / %ggroup name / GIDroot / 0
%ssize in bytes6
%b / %Bnumber of blocks / block size in bytes for %b8 / 512
%iinode number1134952
%hnumber of hard links1
%d / %Ddevice number (decimal / hex)64
%mmount point/
%orecommended I/O block size4096
%x / %Xatime: human-readable / Unix seconds2026-10-13 15:21:52.59… +0000 / 1791904912
%y / %Ymtime: human-readable / Unix seconds
%z / %Zctime: human-readable / Unix seconds
%w / %Wcreation time: human-readable (- if unknown) / seconds (0)
%t / %Tmajor / minor device number (hex) — for /dev/*1 / 3 for /dev/null
%CSELinux context

Width and precision work as in printf: %10s — right-align to 10 characters, %-6s — left-align, %.19y — date without fractional seconds (2026-10-13 15:21:58), %.3Y — seconds with milliseconds.

-c format with -f: file system

CodeWhat it prints
%TFS type in words (ext2/ext3, tmpfs, overlayfs…)
%btotal data blocks
%f / %afree blocks / available to a regular user
%Sblock size for these counters
%c / %dtotal inodes / free inodes
%lmaximum file name length
%npath name

Examples

# permissions in octal — for comparison in a script
stat -c '%a' /etc/shadow

# permissions, owner, group on one line
stat -c '%A %U:%G %n' /etc/passwd /etc/shadow

# size in bytes
stat -c %s backup.tar.gz

# modification time in seconds — handy for computing age
echo $(( $(date +%s) - $(stat -c %Y app.log) ))

# modification date without nanoseconds
stat -c '%.19y' app.log

# a "name — size" table via --printf
stat --printf '%n\t%s\n' *.log

# the link target's data, not the link's
stat -L /etc/localtime

# FS type and free inodes
stat -f -c 'type=%T free inodes=%d' /

Pitfalls

  • -c doesn't understand \t and \n: stat -c '%n\t%s' prints \t literally. For control characters use --printf (and then write the trailing \n yourself).
  • By default a link means the link itself. stat link shows symbolic link, permissions 777 and size = path length. For the target — -L.
  • %a doesn't pad with zeros: after chmod 755 you get 755, after chmod 4755 — 4755. For uniform width — %#a (0755) or %04a.
  • %Y vs %y. For arithmetic use seconds (%Y); the human-readable %y contains nanoseconds and the time zone.
  • %w is often -. Not every FS stores the creation time, and not every tool copies it.
  • This is GNU syntax. On macOS/BSD stat has different flags (-f '%Lp'); scripts using stat -c don't work there.

See also

ls · touch · chmod · chown · find · df-du · date