How to Check File or File System Status in Linux

The stat command in Linux displays detailed information about files and filesystems, including size, permissions, inode, and timestamps.

Alby Andersen

The stat command in Linux provides detailed information about a file or filesystem, including file size, permissions, ownership, and timestamps. It is useful for quickly checking metadata of files and directories.


Display File Information

stat file.txt  


Shows details like size, blocks, inode, permissions, and timestamps for file.txt.


Display Filesystem Information

stat -f /  
  • -f: Displays filesystem information for the root (/) directory.

Show Only File Size

stat -c %s file.txt  
  • -c %s: Outputs only the file size in bytes.

Show File Permissions in Octal Format

stat -c %A file.txt  
  • -c %A: Displays file permissions in human-readable format (e.g., -rw-r--r--).

Show File Owner and Group

stat -c %U:%G file.txt  
  • -c %U:%G: Displays the owner and group of the file (e.g., user:group).

Display File Inode Number

stat -c %i file.txt  
  • -c %i: Outputs the inode number of the file.

Show File Access Time

stat -c %x file.txt  
  • -c %x: Displays the last access time of the file.

Show File Modification Time

stat -c %y file.txt  
  • -c %y: Displays the last modification time of the file.

Show File Change Time

stat -c %z file.txt  
  • -c %z: Displays the last status change time (e.g., permissions or ownership changes).

Display Multiple Custom Attributes

stat -c "Size: %s bytes, Owner: %U, Permissions: %A" file.txt  


Outputs custom-formatted information about the file.


Show Filesystem Block Size

stat -f -c %S /  
  • -f -c %S: Displays the block size of the root (/) filesystem.

Display Filesystem Free Space

stat -f -c %a /  
  • -f -c %a: Shows the number of free blocks on the root (/) filesystem.

Show Filesystem Total Space

stat -f -c %b /  
  • -f -c %b: Displays the total number of blocks on the root (/) filesystem.

Compare File Timestamps

stat -c "Access: %x, Modify: %y, Change: %z" file.txt  


Outputs all three timestamps (access, modify, change) for comparison.


Display Information for Multiple Files

stat file1.txt file2.txt  


Shows details for both file1.txt and file2.txt.


stat -L symlink  
  • -L: Follows the symbolic link and displays information about the target file.

Key Notes:

  • Custom Formatting: Use -c to specify custom output formats.
  • Filesystem Info: Use -f to query filesystem details.
  • Timestamps: Access (%x), Modify (%y), and Change (%z) times are useful for debugging.
Share This Article