Listing as inspection
Choose listing views based on the question you need answered.
ls -la
20 min read, 25 min lab
beginner
`ls` can answer different questions: names, hidden entries, permissions, ownership, sizes, times, and file type hints. The default view is rarely enough for troubleshooting.
A service refuses to read a config file. You need to check owner, group, mode, and timestamp without editing the file.
Worked command
$ ls -la /etc/ssh$ ls -lhtr /var/log | tail$ stat /etc/passwd
Do not parse `ls` output in scripts; use it for human inspection.
Use long listings for metadata and `stat` when one file's exact details matter.
A service can't read one config file and you need its exact owner, group, mode, and timestamp. Which command answers that best, and why?
Show the answer
Correct: C. `stat`, because it reports exact metadata for a single file
`stat` is built to report one file's exact owner, group, mode, and times; `ls`'s default view shows only names, and parsing `ls` output is unreliable and discouraged for scripts.
Practice checklist
- Create files including a dotfile.
- Compare `ls`, `ls -a`, `ls -la`, and `stat`.
- Write what each view proves.
Deliverable evidence
- A table mapping each listing command to the fact it proved.
shows: How `.`, `..`, and `~` resolve from the current directory into a single absolute location, with `pwd`/`realpath` confirming where you actually are and `find` filtering a tree down to evidence.
does not prove: It shows how path tokens resolve in principle; it does not prove your shell's current directory at any moment — only running `pwd` or `realpath` on the live machine proves that.
Commit these to memory, then drill them until recall is automatic.
cue Show hidden entries plus permissions, ownership, size, and time for everything in a directory.
show recall target
ls -la