Getting Help: man, –help, and info
Every command on a Linux system ships with documentation you can read without ever opening a browser. Learning to pull that documentation up quickly — and to understand what you’re looking at — is one of the highest-leverage skills a new Linux user can build, because it means you never have to memorize every flag of every tool. This lesson covers the three main ways to get help at the command line: man pages, the --help flag, and the GNU info system, plus the discovery tools apropos and whatis that help you find the right command in the first place.
Overview / How it works
Most Linux distributions install documentation alongside the software itself. When you install a package with apt (or dnf/yum on RHEL/Fedora), the package usually drops a formatted manual page into a directory like /usr/share/man. These are called man pages, short for “manual pages,” and they’re read with the man command.
Man pages are organized into numbered sections, because the same name can refer to different things. For example, passwd is both a command you run (to change your password) and a file format (/etc/passwd) that describes its structure. The sections are:
| Section | Contents |
|---|---|
| 1 | User commands (executable programs run from the shell) |
| 2 | System calls (kernel functions, for C programmers) |
| 3 | Library functions (C standard library, for C programmers) |
| 4 | Special files (usually device files in /dev) |
| 5 | File formats and configuration file layouts |
| 6 | Games |
| 7 | Miscellaneous (conventions, protocols, overviews) |
| 8 | System administration commands (usually need root) |
When you type man passwd, man searches its configured search path (controlled by the MANPATH environment variable and /etc/manpath.config) for a page named passwd, and by default returns the lowest-numbered section it finds first — usually section 1, the command. To force a specific section, you put the number before the name: man 5 passwd gets you the file format instead.
Under the hood, man pages are plain text files marked up in a typesetting language (historically troff/groff macros), and man formats them for your terminal on the fly, then pipes the result into a pager — almost always less on modern systems. That’s why a man page lets you scroll, search, and quit with q: you’re actually inside less, not a special man-only viewer.
A separate mechanism, the --help flag, is a convention (not a kernel or shell feature) followed by most GNU coreutils and many other programs: the program itself prints a short usage summary and exits. It’s built into the program’s own code, so it’s always in sync with the exact binary installed on your system, but it’s typically much terser than a man page — a quick flag reference rather than a full explanation. Some non-GNU or minimal tools use -h instead of --help, and shell builtins like cd or export don’t have --help at all, because they aren’t separate executables — they’re handled directly by Bash. For those, Bash has its own help command.
Finally, GNU projects such as tar, gcc, bash, and emacs often ship a third documentation format: info pages, built with the Texinfo system. Info pages are hyperlinked and organized into nodes you can jump between, which makes them better suited to long, structured manuals than the flat, scroll-only format of a man page.
Syntax
man [section] command
command --help
command -h
info command
apropos keyword
whatis command
man [section] command— opens the manual page forcommand, optionally forcing a specific section number.command --help— prints a short usage summary directly from the program (GNU convention).command -h— the short form of--helpused by some non-GNU tools.info command— opens the hyperlinked Texinfo manual, if one exists.apropos keyword— searches man page names and short descriptions for a keyword, useful when you don’t know the exact command name.whatis command— prints the one-line description of a command from its man page, without opening the full page.
Examples
Start with the most common case: reading the manual for a command you already know the name of.
man ls
LS(1) User Commands LS(1)
NAME
ls - list directory contents
SYNOPSIS
ls [OPTION]... [FILE]...
DESCRIPTION
List information about the FILEs (the current directory by default).
-a, --all
do not ignore entries starting with .
-l use a long listing format
Manual page ls(1) line 1 (press h for help or q to quit)
This opens inside less. Press space to page down, /all then Enter to search for the word “all”, n to jump to the next match, and q to quit and return to your prompt. Nothing here modifies your terminal permanently — the man page simply takes over the screen until you quit it.
Next, get a fast flag reminder for a command you mostly already know how to use, without leaving the man page’s terser cousin:
tar --help
Usage: tar [OPTION...] [FILE]...
GNU 'tar' saves many files together into a single tape or disk archive.
Examples:
tar -cf archive.tar foo bar # Create archive.tar from files foo and bar.
tar -tvf archive.tar # List all files in archive.tar verbosely.
tar -xf archive.tar # Extract all files from archive.tar.
... (truncated) ...
--help output prints straight to your terminal and exits immediately — there’s no pager, no scrolling, and no q needed. That makes it ideal when you just need to check a flag’s spelling while writing a command, rather than learning the tool from scratch.
Finally, suppose you want to back up a directory but can’t remember whether the command for that is called archive, backup, or something else. Use apropos to search by keyword instead of guessing the exact name:
apropos "copy files"
cp (1) - copy files and directories
install (1) - copy files and set attributes
rsync (1) - a fast, versatile, remote (and local) file-copying tool
apropos searches the short one-line NAME descriptions that every man page includes, using a database (mandb) built ahead of time by scanning all installed man pages. This is why a freshly-installed package’s man page sometimes doesn’t show up in apropos results until mandb is rebuilt, either automatically by a package hook or manually with sudo mandb.
How it works step by step
When you run man ls, this is roughly what happens: man reads its configuration to determine the search path, looks through each directory in that path for a file named ls.1 (or a compressed ls.1.gz) in a man1 subdirectory, decompresses and formats the found file into terminal-ready text, and pipes that formatted text into the pager named by your $PAGER environment variable, defaulting to less. The pager then takes over your terminal, reading your keystrokes for scrolling and searching, until you quit with q, at which point control returns to your shell.
command --help works completely differently: there’s no search, no formatting step, and no pager. The command binary itself contains the help text as a string in its own source code; when it sees --help as an argument, it just prints that string to standard output and exits with status 0 before doing anything else. That’s also why --help is always accurate for the exact version of the binary installed, while a man page is a separate file that could theoretically drift out of sync (though in practice, package maintainers keep them together).
Common Mistakes
Mistake 1: assuming every command supports --help, including shell builtins. Builtins like cd, export, and alias aren’t separate programs on disk — they’re part of Bash itself, so there’s no executable for --help to run against.
$ cd --help
bash: cd: --: invalid option
cd: usage: cd [-L|[-P [-e]] [-@]] [dir]
Use Bash’s own help command for builtins instead, and type to check whether something is a builtin before reaching for --help at all:
type cd
help cd
Mistake 2: reading the wrong man section and concluding the documentation is wrong. Running man printf shows the shell/coreutils command by default, but if you’re writing C and want the standard library function, you need to force section 3 explicitly, since man otherwise stops at the first (lowest-numbered) match it finds:
man printf
man 3 printf
If you’re ever unsure which sections exist for a name, man -k printf (equivalent to apropos printf) lists every section that has a matching page.
Best Practices
- Reach for
manfirst when you need the full picture — every option explained, exit statuses, related commands, and often examples at the bottom under an EXAMPLES heading. - Reach for
--helpwhen you already know the tool and just need to confirm a flag’s exact spelling. - Use
infofor GNU tools with deep functionality (tar,gcc,bash,coreutils) — their info manuals are often more complete and better organized than their man pages. - Use
apropos keyword(orman -k keyword) when you don’t know the command’s exact name but can describe what it does. - Use
whatis commandfor a one-line reminder of what a command does, without opening the full page. - Inside a man page, use
/patternto search forward,nto repeat the search, andqto quit — it’s the same navigation as thelesspager, so it’s worth learning once and reusing everywhere. - If
aproposreturns nothing for a package you just installed, rebuild the search database withsudo mandb.
Practice Exercises
Exercise 1: Find the man page that documents the file format of /etc/crontab, as opposed to the page for the crontab command itself. Which section number is it in?
Exercise 2: You want to check how much disk space directories are using, but you can’t remember the command name. Use apropos with a relevant keyword to find it, then confirm what it does with whatis.
Exercise 3: Determine whether echo on your system is a Bash builtin, an external program, or both, using type -a echo. Then try getting help for it both ways (help echo and echo --help, if applicable) and compare the output.
Summary
man commandopens the full manual page, formatted and displayed through a pager likeless; quit withq.- Man pages are split into numbered sections (1 = user commands, 5 = file formats, 8 = admin commands, etc.); force a section with
man 5 namewhen a name exists in more than one. command --helpprints a short usage summary directly from the program itself and exits — fast, but not exhaustive, and unavailable for shell builtins.- Shell builtins (
cd,export, etc.) use Bash’s ownhelpcommand instead of--help; check withtypefirst. info commandopens a hyperlinked Texinfo manual, often more thorough than the man page for GNU tools.apropos keywordsearches man page descriptions to help you find a command by what it does;whatis commandgives a one-line summary.
