Skip to content

What is stat Linux command?

The Linux stat command is used to display detailed file or file system status information. This powerful command provides access to a wide range of data, including file type, permissions, size, access time, modification time, inode number, and much more.

stat Syntax:

Terminal window
stat [option] [file]

stat Options:

OptionDescription
-LFollow symbolic links
-cDisplay information in specified format
-fDisplay file system status instead
-tShow information in a terse format
-hPrint help message
-VPrint version information

Parameters:

ParameterDescription
fileSpecify the file to retrieve information

stat Command Usage Examples:

Check File Information

Terminal window
stat filename.txt

Displays detailed information about the file “filename.txt”.

Display File Inode Number

Terminal window
stat -c %i filename.txt

Shows the inode number of the file “filename.txt”.

View File Permissions in Octal Format

Terminal window
stat -c %a filename.txt

Prints the file permissions of “filename.txt” in octal format.

Show File Birth Time

Terminal window
stat -c %w filename.txt

Retrieves the birth time of the file “filename.txt”.

Get Device ID and Inode in Human-Readable Format

Terminal window
stat -c "Device: %D Inode: %i" filename.txt

Displays the device ID and inode of “filename.txt” in a human-readable format.

{Questions}

Applications of the stat command

  • Checking file or directory details
  • Retrieving information on file size
  • Determining file permissions
  • Viewing file timestamps
  • Checking information on file type