2.2 Using the Command Line to Get Help
Key Takeaways
- man displays the manual page for a command, file format, or topic; press q to quit the pager and use /pattern to search within a page
- Manual pages are grouped into numbered sections — section 1 is user commands, 5 is file formats, 8 is administration commands
- info often provides a hyperlinked Texinfo manual that can be deeper than a short man page; navigate with arrows, Enter, and q to quit
- /usr/share/doc/ holds packaged documentation (README, HTML, examples) installed with software on many distributions
- locate searches a prebuilt filename database for path matches and is typically faster than a full filesystem find for name lookups
When you forget a switch or meet an unfamiliar command, Linux expects you to help yourself from the terminal. Objective 2.2 covers the classic help stack: man, info, files under /usr/share/doc/, and locate for finding documentation or other files by name.
man: The System Manual
man ls
man 5 passwd
man man
man formats a manual page and sends it to a pager (commonly less). Essential pager keys:
| Key | Action |
|---|---|
Space / f | Next page |
b | Previous page |
Arrow keys / j k | Line movement |
/pattern | Search forward for pattern |
n | Next search hit |
q | Quit back to the shell |
A typical man page includes NAME, SYNOPSIS, DESCRIPTION, OPTIONS, and sometimes EXAMPLES or SEE ALSO. Read the SYNOPSIS carefully: square brackets mean optional items; | separates alternatives; ellipses ... mean “more of the same.”
Manual Sections
Pages are stored in numbered sections. The same name can exist in more than one section (classic example: passwd).
| Section | Contents | Example |
|---|---|---|
| 1 | Executable user commands | man 1 ls |
| 2 | System calls | man 2 open |
| 3 | Library functions | man 3 printf |
| 4 | Special files (devices) | man 4 null |
| 5 | File formats and conventions | man 5 passwd |
| 6 | Games | (rarely needed) |
| 7 | Miscellany (protocols, standards) | man 7 man |
| 8 | System administration commands | man 8 useradd |
For Essentials, prioritize 1, 5, and 8. If man passwd shows the command instead of /etc/passwd’s format, request the section explicitly: man 5 passwd.
whatis ls # one-line summary from the whatis database
man -k copy # approximate keyword search (same idea as apropos)
man -k / apropos search short descriptions — useful when you remember what you want but not the command name.
info: Hyperlinked Texinfo Manuals
GNU projects often ship richer documentation as Info documents:
info ls
info coreutils
info bash
Info readers present a menu of nodes. Common navigation:
| Action | Typical key |
|---|---|
| Follow a menu item | Enter on the link |
| Next / previous node | n / p (in many info readers) |
| Up to parent menu | u |
| Quit | q |
| Search | s then pattern |
Compared with man, info manuals may include tutorials and deeper cross-links. If man feels too terse, try info for the same topic. Not every command has an Info document; when none exists, the reader says so and you fall back to man or /usr/share/doc/.
/usr/share/doc/: Packaged Documentation
Distributions install per-package documents under /usr/share/doc/:
ls /usr/share/doc/
ls /usr/share/doc/bash/
less /usr/share/doc/bash/README
You often find README, changelog, copyright, example configs, and HTML manuals. This tree is ideal when:
- You need examples or packaging notes not in the man page.
- A package ships a long HOWTO only as a file.
- You are browsing offline on a minimal server.
Remember the path itself — fill-in questions may ask where additional documentation is stored, and /usr/share/doc/ is the expected answer.
locate: Fast Name Search
locate passwd
locate '*.desktop'
locate README | head
locate queries a prebuilt database of file paths (updated by a periodic job such as updatedb). Strengths and caveats:
| Aspect | Behavior |
|---|---|
| Speed | Usually much faster than walking the whole disk with find |
| Freshness | May miss brand-new files until the database is refreshed |
| Scope | Matches path substrings; use patterns carefully |
| Privilege | Database may omit directories the indexing user could not read |
For objective 2.2, use locate to find documentation files or command paths by name. Example workflow:
locate bash | grep '/usr/share/doc'
# narrow results to documentation paths
Do not confuse locate with which/type (command resolution) or with man -k (description search). Each tool answers a different question.
When to Use Which Helper
| Need | Start with |
|---|---|
| Exact options for a known command | man command |
| File format of a config (e.g. passwd structure) | man 5 name |
| Broader GNU tutorial / linked chapters | info topic |
| README / examples shipped with a package | Browse /usr/share/doc/package/ |
| “Where is that file?” by name | locate pattern |
| “What command mentions backup?” | man -k backup or apropos backup |
Worked Scenario
You need the meaning of chmod’s symbolic mode and also want the package’s README:
man 1 chmod # read OPTIONS and examples; q to quit
info coreutils # optional deeper GNU docs if installed
ls /usr/share/doc/coreutils/
locate 'chmod*'
If man chmod opens but you cannot leave, you forgot q. That navigation detail appears in training materials because new users often feel “stuck” inside the pager.
One-Line Summaries and Keyword Search
Before opening a full page, you can ask the whatis database for a short description:
whatis printf
apropos editor
man -k permission
whatis (and the related man -f) expects a name and returns a concise summary. apropos / man -k search those summaries for a keyword, which helps when you remember the task (“compress”, “calendar”, “password”) but not the utility. If the database was never built on a minimal install, these helpers may return nothing until the administrator generates the index — another reminder that help tools depend on local documentation packages being present.
Sometimes the same name exists in multiple sections. man -a passwd walks through every matching page so you can compare the command (section 1) with the file format (section 5). On a timed exam item, naming the section explicitly is faster and clearer than paging through every hit.
Choosing Help Under Time Pressure
Walk a decision path the way you will on test day:
- You know the command name and need flags → start with
man command(section 1 by default). - You know a config file name and need field meanings → try
man 5 nameor look under/usr/share/doc/for examples. - The man page is too short or points you to a Texinfo manual → run
infoon the same topic. - You do not know where a README or example file lives →
locatea distinctive fragment of the path or filename, then open it withless. - You only remember a verb (“schedule”, “archive”) →
man -k/aproposto discover candidate commands, then read their man pages.
That sequence keeps you from randomly mixing tools. locate will not explain options; man will not search the whole disk for a misplaced example script; /usr/share/doc/ will not refresh itself when you invent a new file in /tmp.
locate Freshness and Permissions
Because locate reads a database (commonly maintained by updatedb via cron or a systemd timer), results can lag. A file you created moments ago may be invisible until the next update. Conversely, a deleted file might still appear until the database is rebuilt. If a locate search surprises you, consider freshness before assuming the file never existed.
Permissions also matter: paths the indexer could not read may be absent from the database. For Essentials, remember the design goal — fast name lookup from an index — and contrast it with a live recursive search that walks directories in real time (deeper find skills show up more in later objectives).
Exam Tips
- Match the tool to the job:
manfor reference pages,infofor Texinfo manuals,/usr/share/doc/for packaged files,locatefor path search. - Know section numbers at least for 1 (commands) and 5 (file formats).
- Know
qexits the man/info pager;/searches insideless. locatedepends on its database — a missing recent file is not always a failure of the command itself.- Prefer
man -k/aproposwhen you have a keyword but not a command name; preferwhatiswhen you already have the name and want a one-line reminder.
With these helpers, you can answer “what does this switch do?” without leaving the command line — exactly the skill Linux Essentials weights in Topic 2.
Which command opens the manual page describing the format of the /etc/passwd file rather than the passwd command?
While reading a man page in the usual pager, which key returns you to the shell prompt?
Where do many Linux distributions store package-shipped README files and other supplemental documentation?
What is the main advantage of using locate filename instead of walking the entire filesystem for a name match?