Command anatomy and help
Read commands as command, options, arguments, and input source.
man ls
20 min read, 20 min lab
beginner
Most shell commands have a shape: the executable, options that change behavior, and arguments that name targets. The manual page is not trivia; it is part of the workflow. Operators memorize the shape and know where to verify flags.
You need a long directory listing sorted by time, but you do not trust a copied command from a forum.
Worked command
$ ls -lhtr /var/log# command: ls# options: -l -h -t -r# argument: /var/log$ man ls$ ls --help | sed -n '1,18p'
Do not copy flags you cannot explain when files or services are on the line.
Parse the command first, then verify unknown options with man or --help.
In `grep -rn "error" /var/log`, how does the command break down into executable, options, and arguments?
Show the answer
Correct: A. grep is the executable, -rn are options, "error" and /var/log are arguments
Options start with a dash and change behavior (-r recursive, -n line numbers); everything else is an argument, here the pattern "error" and the target /var/log. The pattern is a positional argument, not an option, even though it sits between the flags and the path.
Practice checklist
- Pick three commands from this page.
- Split each into executable, options, and arguments.
- Find one option in the manual for each command.
Deliverable evidence
- Three annotated command shapes.
- A note explaining one flag you looked up.
shows: The chapter's operator loop: read prompt state, parse the command into executable/options/arguments and verify it, run it, then read exit status and stderr before the next move.
does not prove: It does not prove a zero exit status means the intended effect happened, nor that the prompt's displayed host, path, or privilege are accurate; both must be confirmed with commands when consequences matter.
Commit these to memory, then drill them until recall is automatic.
cue You copied a command with a flag you cannot explain and files are on the line. What do you do before running it?
show recall target
Parse it into executable/options/arguments, then verify the unknown flag with man or --help