stat
everything about one filestat prints a file’s metadata in full. Where ls -l gives one line, stat gives the inode, the mode in octal, and three or four separate times — the detail you need when a permission or a date does not add up.
A file has three times, not one: when it was read, when its contents changed, and when its metadata changed.
At the terminal
Read the session first, then the notes: each numbered line in the output is answered by the note with the same number.
What the numbered lines are telling you
2048 bytes, occupying 8 blocks of 512 bytes on disk, and an ordinary file rather than a directory or link.
A name is only a pointer to an inode. Links: 1 means one name points at this one.
0644 is the octal form chmod takes; the letters are what ls shows. Owner and group are given as number and name.
Modify is when the contents last changed. Change is when the metadata did — here a chmod or chown twelve seconds later.
Switches
A switch changes how the command behaves. These are the ones used day to day; man stat lists the rest. Single-letter switches can usually be joined, so -l -a may be written -la.
-c FORMAT- Print only the fields named, such as %a for octal mode and %n for name.
-f- Describe the filesystem the file is on, not the file.
-L- Follow symbolic links and describe the target.
-t- Terse: print everything on one line, for scripts.
Variations worth knowing
The same tool, pointed at a narrower question. These four cover most of what it is reached for day to day.
stat -c "%a %U:%G %n" *Prints octal mode, owner, group and name for every file here.
stat -c %s file.isoPrints only the size in bytes.
stat -f /Describes the filesystem rather than a file: type, block size, free space.
stat -L currentFollows a symbolic link and describes the file it points to.
In cybersecurity
The three timestamps are the basic evidence of what happened to a file.
touch can set Access and Modify to any date, but the kernel sets Change itself. A Modify older than Change means the date was altered or the metadata was.
A leading 4 or 2 — 4755 — is set-uid or set-gid. stat shows it plainly where ls shows only an s in the letters.
On some mounts every read updates Access. Investigators copy or mount read-only first, so looking does not overwrite the evidence.