stat
file systemLinux/Unix
The stat command is one of the most frequently used commands in Linux/Unix-like operating systems. stat Display file or file system status
Quick Reference
Command Name:
stat
Category:
file system
Platform:
Linux/Unix
Basic Usage:
stat [options] [arguments]
Common Use Cases
Syntax
stat [options] file...
Options
Option | Description |
---|---|
-L, --dereference |
Follow links |
-f, --file-system |
Display file system status instead of file status |
-c, --format=FORMAT |
Use the specified FORMAT instead of the default |
--printf=FORMAT |
Like --format, but interpret backslash escapes |
-t, --terse |
Print the information in terse form |
--help |
Display help and exit |
--version |
Output version information and exit |
Format Sequence | Description |
---|---|
%a |
Access rights in octal |
%A |
Access rights in human-readable form |
%b |
Number of blocks allocated |
%B |
The size in bytes of each block |
%d |
Device number in decimal |
%D |
Device number in hex |
%f |
Raw mode in hex |
%F |
File type |
%g |
Group ID of owner |
%G |
Group name of owner |
%h |
Number of hard links |
%i |
Inode number |
%m |
Mount point |
%n |
File name |
%N |
Quoted file name with dereference if symbolic link |
%o |
Optimal I/O transfer size hint |
%s |
Total size, in bytes |
%t |
Major device type in hex, for character/block device special files |
%T |
Minor device type in hex, for character/block device special files |
%u |
User ID of owner |
%U |
User name of owner |
%w |
Time of file birth, or -1 |
%W |
Time of file birth as seconds since Epoch, or 0 |
%x |
Time of last access |
%X |
Time of last access as seconds since Epoch |
%y |
Time of last data modification |
%Y |
Time of last data modification as seconds since Epoch |
%z |
Time of last status change |
%Z |
Time of last status change as seconds since Epoch |
File System Format Sequence | Description (with -f option) |
---|---|
%a |
Free blocks available to non-superuser |
%b |
Total data blocks in file system |
%c |
Total file nodes in file system |
%d |
Free file nodes in file system |
%f |
Free blocks in file system |
%i |
File system ID in hex |
%l |
Maximum length of filenames |
%n |
File name |
%s |
Block size (for faster transfers) |
%S |
Fundamental block size (for block counts) |
%t |
Type in hex |
%T |
Type in human-readable form |
Examples
How to Use These Examples
The examples below show common ways to use the stat
command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.
# Basic Examples Basic
stat file.txt