Back to the command reference

stat

FilesFundamentals In simulator In real Linux

Show detailed file status

Name: stat = status

You can practise it right away in the simulator, and use it in real Linux mode too.

Description

stat shows a file's metadata in detail: size, blocks, inode number, link count, permissions (both octal and symbolic), owner, and the access, modify and change times.

-c prints just the fields you ask for in a custom format, useful in scripts.

Syntax

stat [OPTION]... FILE...

Common options

-c / --format FORMATCustom format, e.g. %s size, %a mode, %y mtime
--printf FORMATLike -c, with escapes such as \n and no newline added
-f / --file-systemShow file system status instead
-L / --dereferenceDescribe what a symbolic link points to
-t / --terseTerse: everything on one line

Examples

  • $ stat README.md

    Size, permissions, inode and timestamps

    Explain
  • $ stat -c "%a %n" *

    Octal permissions of every file

    Explain

Related