Skip to main content

stat (Status)

Explanation

The stat command displays detailed information about a file or file system. It provides much more information than ls -l, including access, modify, and change timestamps, file size, blocks allocated, inode number, and permissions.

Basic Syntax

stat [OPTION]... FILE...

Common Flags and Options

FlagDescription
-L, --dereferenceFollow links (display info for target, not the link itself).
-f, --file-systemDisplay file system status instead of file status.
-c, --format=FORMATUse the specified FORMAT instead of the default.
--printf=FORMATLike --format, but interpret backslash escapes.

Real-world Examples

  1. View standard file statistics:

    stat myfile.txt
  2. View filesystem information instead of file info:

    stat -f /
  3. Output only the file permissions in octal format:

    stat -c "%a" myfile.txt