Stat Command Overview
The stat
command displays detailed file or filesystem status information. It’s commonly used by developers and sysadmins to inspect metadata such as permissions, ownership, timestamps, and filesystem-specific attributes.
Synopsis
stat [OPTION]... FILE...
Key Options
-c, --format=FORMAT
Use a custom format string (see FORMAT below).-f, --file-system
Display information about the filesystem instead of the file itself.-L, --dereference
Follow symlinks (show info for the target).--printf=FORMAT
Like-c
but without trailing newline.-t, --terse
Print in terse (single-line) format.
Default Output Example
$ stat example.txt
File: example.txt
Size: 1024 Blocks: 8 IO Block: 4096 regular file
Device: 802h/2050d Inode: 264457 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 1000/ alice) Gid: ( 1000/ alice)
Access: 2025-06-13 14:22:10.000000000 +0200
Modify: 2025-06-12 09:15:45.000000000 +0200
Change: 2025-06-12 09:15:45.000000000 +0200
Birth: 2025-06-10 08:00:00.000000000 +0200
Field Breakdown
Field | Description |
---|---|
File | Path to the file being inspected. |
Size | Total size in bytes. |
Blocks | Number of 512-byte blocks allocated. |
IO Block | Filesystem I/O block (optimal transfer) size in bytes. |
regular file / directory / … | File type. |
Device | Device number in hex/decimal. |
Inode | Inode number (unique file system identifier). |
Links | Number of hard links. |
Access | File permissions (octal and symbolic), then UID and GID with names. |
Access | Last access timestamp (atime). |
Modify | Last data modification timestamp (mtime). |
Change | Last status change timestamp (ctime). |
Birth | Creation timestamp (if supported by filesystem). |
Custom Formatting
You can extract specific fields using -c
/--format
. For example:
stat -c 'Size: %s bytes%nModified: %y%nPerm: %A' example.txt
Common Format Sequences
Specifier | Meaning |
---|---|
%n | File name |
%s | Total size in bytes |
%b | Number of blocks |
%F | File type |
%i | Inode number |
%h | Number of hard links |
%U | User name of owner |
%G | Group name of owner |
%a | Access rights in octal |
%A | Access rights in human-readable form (-rw-r--r-- ) |
%x | Time of last access |
%y | Time of last modification |
%z | Time of last status change |
Example: Filesystem Status
$ stat -f /home
File: "/home"
ID: 74ef3f7d5e83b4e4 Namelen: 255 Type: ext2/ext3
Block size: 4096 Fundamental block size: 4096
Blocks: Total: 244190560 Free: 178103412 Available: 167035968
Inodes: Total: 62464000 Free: 62123412
This shows filesystem‐level metrics such as total blocks, free blocks, inode counts, and the filesystem type.
Use man stat
for the full list of options and format specifiers.