Pebellslearn by building
0%
RoadmapsMatrixCoursesSandboxSign in
Shell and Other Basics  ›  Lesson

Command Help — Asking the System Itself

Command Help 10 minUse --help for a quick summary, man for the full manual with numbered sections, man -k to find a command by topic, and help for shell builtins.

Command Help — Asking the System Itself

Nobody remembers every option of every command. Experienced Linux users aren't people who know everything. They're people who know how to look things up in seconds, without leaving the terminal. The documentation is already installed, and you just need to know how to reach it.

The rule

Ask the command first: --help for a glance, man for the full story.

--help prints a short summary straight to the terminal. Most GNU commands support it:

$ sort --help
Usage: sort [OPTION]... [FILE]...
  -n, --numeric-sort    compare according to string numerical value
  -r, --reverse         reverse the result of comparisons
...

man opens the full manual page:

$ man sort

The page opens in a pager (usually less), and a few keys are all you need:

Key Does
Space / b page down / back
/word search for "word"; n goes to the next match
q quit

Manual pages are split into numbered sections, and the section number appears in brackets, as in passwd(1):

Section Holds
1 user commands
5 file formats, such as config files
8 administration commands

So man passwd shows the passwd command, and man 5 passwd shows the format of the /etc/passwd file.

Don't know the command's name? Search the short descriptions of every manual page:

$ man -k compress        # same as: apropos compress
gzip (1)   - compress or expand files
...

Shell builtins such as cd and export are part of the shell itself, so they may not have their own man page. In Bash, help cd explains them. type cd tells you whether something is a builtin.

The shortcut

Climb one rung at a time: --help first, then man, then man -k. Start with the quick answer and only go deeper if you need to.

How does Asha sort by the third column?Step 1 of 4
  1. Glance

    sort --help mentions -t for the separator and -k for the key, but not how to combine them.

Two traps. man shows the manual for the version installed on this machine, which can differ from what a website describes, and that's a good reason to trust it. And typing man cd in Bash may show a general builtins page or nothing, because cd is built into the shell. Use help cd instead.

Drills

Answer fast — trust the rule.

quick drill

What is the quickest way to see a short list of tar's options in the terminal?

quick drill

Inside a man page, how do you search for the word "recursive"?

quick drill

You want the format of the /etc/passwd file, not the passwd command. Which command shows it?

quick drill

You need a command that makes archives but don't know its name. What's the best start?

Remember

  • Ask the command first: --help for a glance, man for the full story.
  • Climb one rung at a time: --help, then man, then man -k when you don't know the name.
  • In a man page, / searches and q quits. Use help for shell builtins like cd.

Practice — level up

0/1 solved

Write your answer, then compare it with a rubric and a model answer.

ExplainFind it yourself

You need to know how to make sort compare numbers, and separately you need a tool that compresses files but you do not know its name. Describe exactly how you would find both answers without leaving the terminal.