Display detailed metadata about files and filesystems.
low risk
stat shows comprehensive file metadata: inode number, permissions in both octal and symbolic form, link count, ownership, file size, and all three timestamps (access, modify, change). Far more informative than ls -l for debugging permission and timing issues.
| Flag | Meaning |
|---|---|
-c --format | Use a custom output format |
-f --file-system | Show filesystem status instead |
-L --dereference | Follow symlinks |
stat /etc/passwdShow full metadata including timestamps and permissions · explain & risk-check →stat -c '%a %n' /etc/ssh/sshd_configPrint octal permissions and filename only · explain & risk-check →stat -f /Show root filesystem statistics · explain & risk-check →stat -c '%U:%G' /opt/appShow owner:group only · explain & risk-check →Use `stat -c '%a'` in scripts to check exact octal permissions — more reliable than parsing `ls -l` output which varies by implementation.
Reference text is hand-written and may be incomplete — check man stat for your version. Test destructive commands on a non-production system first.