stat - chapter 1 interface to chapter 2 system call


stat [ options ] file(s)


stat prints some or all of a file's "meta information"--size, modification time, permissions, owner, etc. This is the information that, on Unix systems, anyway, is kept in the ``inode'' and fetched using the stat(2) system call. In short, this program is simply a command-line-callable interface to that system call.

By default, stat prints all available information for the one or more filenames specified. The options permit selection of only certain information to be printed, or in various formats.

Under Unix, the special filename argument ``-'' indicates stdin, which is stat'ed using fstat(2).

On systems which support symbolic links, stat prints information about the linked-to file, not the link. (That is, it uses the stat(2) system call by default, as its name suggests, not lstat(2).) Information about the link itself may be obtained by (a) using the -l option, or (b) creating a second link to the stat command itself, named lstat, and invoking that. (For completeness, and to mimic ls(1), the -L option effectively turns lstat back into stat.)

If any of the options below are used to select particular fields, only the selected fields are printed. If no particular fields are selected, all fields are printed.


Print the last-accessed time (st_atime).
Print the underlying block size (st_blksize).
Print the number of storage blocks used (st_blocks).
Print the inode changed time (st_ctime).
Print the underlying device (st_dev).
-f str
Overriding other output-specifying options, print one line of output for each file, driven by the string str, which contains % signs and other text. The % signs introduce 2-character sequences which interpolate stat values in with the surrounding text. (This is obviously modeled after C library functions such as printf and strftime.) The available % sequences are: (Note that the % characters largely match the other single-character command line flags.)
Print the owning GID (st_gid).
Print a brief help message.
Print the inode number (st_ino).
If a file is a symbolic link, print information about the link, not the linked-to file. (That is, use lstat(2) rather than stat(2). This is the default if this program is invoked via its own link named lstat.)
If a file is a symbolic link, print information about the linked-to file, not the link. (That is, use stat(2) rather than lstat(2). This is the default if this program is named stat.)
Print the modification time (st_mtime).
Print the number of links (st_nlink).
Print file permission modes (st_mode).
Semi-quiet mode: don't print times as ctime(3) strings, UID's and GID's as names, or file permissions as ls-style.
Very quiet mode: don't print any extraneous verbage; print raw values only. (Most useful when only one or two values are selected.)
For device files, print the referenced device (st_rdev).
Print the size in bytes (st_size).
Print the owning UID (st_uid).
Print version number information (of the stat program itself, not of any file).


stat(2), fstat(2), lstat(2)

See for possible updates.


Steve Summit,