What extra information does stat show compared to ls -l?
stat prints a file's full metadata: exact size, blocks, inode number, link count, permissions in octal and symbolic form, owner, and three timestamps (access, modify, change). ls -l shows only a short summary.
Explain it simply
ls -l is the visiting card; stat is the full record. Both describe the same file, but stat leaves nothing out.
Key fields: Size in bytes, Blocks actually used on disk, Inode number (two hard links share it), Links count, Access with octal mode like 0644 and symbolic -rw-r--r--, and Uid/Gid with names.
The three times are worth knowing. Access is last read, Modify is when the contents last changed, and Change is when the metadata (permissions, owner, name) last changed. A chmod updates Change but not Modify. There is no true creation time in the classic fields, though newer systems may show a Birth line.
stat -c '%a %U %s' file prints just the octal mode, owner and size, which is useful in scripts.
Example
stat -c '%a %U %s %n' /etc/passwd
# 644 root 2345 /etc/passwd
stat notes.txt | grep -E 'Inode|Links'What to say in the interview
"stat shows complete metadata: inode, size in bytes and blocks, octal permissions, owner and the access, modify and change times. I use it to check exact permissions in octal or an inode number when investigating hard links."
Common mistakes
- Confusing Modify (content changed) with Change (metadata changed).