stat

stat displays the detailed status of a file. Where ls gives you a line per file, stat gives you everything the system records about one file: its type, its size, its timestamps, and the low-level metadata stored in its inode.

stat [options] file...

stat is a diagnostic tool. It dumps what a file's inode physically contains, verbatim. That makes it the right command for "tell me exactly what is recorded about this file" — and it means some of what it prints needs a word of explanation, below.

The default output #

With no options, stat prints a labelled, multi-line block per file:

$ stat notes.txt
  File: notes.txt
  Size: 219             Blocks: 8          IO Block: 4096   regular file
Device: 8,2     Inode: 1572931     Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1000/    jack)   Gid: ( 1000/    jack)
Access: 2026-05-15 11:03:42.000000000 +0000
Modify: 2026-05-15 11:03:42.000000000 +0000
Change: 2026-05-15 11:03:18.000000000 +0000
 Birth: 2026-05-15 11:03:18.000000000 +0000

Reading it line by line:

  • File — the name, and for a symbolic link, what it points to.
  • Size / Blocks / IO Block / type — the size in bytes, the number of allocated disk blocks, the preferred I/O block size, and the file type in words.
  • Device / Inode / Links — the device the file lives on, its inode number (its unique index within that device), and the number of hard links to it.
  • Access / Uid / Gid — a numeric owner id, a group id, and a mode value. See the caveat below — these are not the access policy.
  • Access / Modify / Change / Birth — four timestamps: when the file was last read, last written, last had its metadata changed, and first created.

The Uid, Gid, and mode fields are decorative #

The Access: (0644/-rw-r--r--) Uid: (…) Gid: (…) line needs care.

A file's inode carries a numeric owner id, a numeric group id, and a mode value, and stat reports them because stat reports the inode verbatim. But the Peios access model does not consult these fields. What a principal may do to a file is decided by the file's security descriptor — see Security descriptors. The numbers on the Uid/Gid/mode line are inert metadata: they are stored, they are reported, and they have no effect on any access decision.

Do not read that line as a permission summary. A file showing 0644 is not "world-readable" in any meaningful sense — whether anyone can read it depends entirely on its security descriptor. stat shows these fields for completeness as a low-level diagnostic; it does not claim they mean anything.

To see the parts of a file's security that do count, use ls -l, which shows the owner SID and the mode column built from the security descriptor.

Custom output formats #

Two options replace the default block with output you control.

OptionEffect
-c FORMAT, --format=FORMATPrint FORMAT for each file, substituting % directives. A newline is added after each file.
--printf=FORMATLike --format, but interpret backslash escapes (\n, \t) in FORMAT and add no trailing newline. Include \n yourself if you want one.
$ stat --format='%n is %s bytes' notes.txt
notes.txt is 219 bytes

File directives #

Used in the format string when stating files (the default mode):

DirectiveSubstitutes
%nFile name.
%NQuoted file name; for a symlink, with the target shown.
%FFile type in words (regular file, directory, …).
%sTotal size, in bytes.
%bNumber of allocated blocks.
%BSize in bytes of each block counted by %b.
%oPreferred I/O transfer block size.
%iInode number.
%hNumber of hard links.
%d / %DDevice number, in decimal / in hexadecimal.
%t / %TFor a device file, the major / minor device type, in hexadecimal.
%mMount point of the file system the file is on.
%fRaw mode value, in hexadecimal.
%x / %XLast access time — human-readable / seconds since the epoch.
%y / %YLast modification time — human-readable / seconds since the epoch.
%z / %ZLast status-change time — human-readable / seconds since the epoch.
%w / %WFile creation (birth) time — human-readable / seconds since the epoch. - or 0 if unknown.

The directives %a and %A (the mode in octal and in symbolic form) and %u, %U, %g, %G (the owner and group, numeric and by name) report the decorative inode fields described above. They are available for completeness; they are not the file's access policy.

The %C directive (security context) is inactive — it produces no meaningful value on a standard Peios system.

File-system directives #

With -f, stat reports on the file system a file lives on rather than the file itself, and the format string uses a different directive set:

DirectiveSubstitutes
%nFile name.
%iFile-system ID, in hexadecimal.
%t / %TFile-system type — in hexadecimal / in words.
%lMaximum length of a file name.
%sBlock size, for fast transfers.
%SFundamental block size, used for the block counts.
%bTotal data blocks in the file system.
%fFree blocks.
%aFree blocks available to an ordinary principal.
%cTotal inodes (file nodes).
%dFree inodes.

Options #

OptionEffect
-f, --file-systemReport on the file system containing each file, instead of the file.
-L, --dereferenceFollow symbolic links — report on the link's target rather than the link itself.
-t, --tersePrint the information on a single line, as bare values with no labels. Useful for scripts.

Exit status #

CodeMeaning
0Every file was stated successfully.
1A file could not be stated, or an option or format directive was invalid.

Edit this page