Glossary

stat

stat shows the metadata the kernel keeps about a file: inode number, size, block usage, permissions, owner, group, and the three timestamps: access, modify, change.

stat file.txt                   # human-readable summary
stat -c '%n %s %y' *.log        # custom format: name, size, mtime
stat -f /                       # filesystem stats for the mount containing /
stat --printf '%s' file         # only the size

The underlying system call is stat(2); stat is the command-line wrapper. Format specifiers mirror the fields of struct stat, so the same mental model applies when reading C code that calls stat().

Related terms: ls, file, Inode

Discussed in:

Textbook of Linux — Learn Linux on iPhone — Download on the App Store