Linux provides various methods for accessing documentation on commands, ranging from simple help prompts to detailed manual pages (man) and hyperlinked info pages. Understanding these tools allows users to efficiently search for command details, syntax, and options.
This article explores different ways to retrieve command documentation, including help, --help, man, apropos, whatis, and info.
Using help for Shell Builtins
The help command provides built-in documentation for shell commands (builtins) in Bash.
Syntax
help command
Here, command is the name of a shell builtin (e.g., cd, echo, exit).
Example: Getting Help on cd
help cd
The output provides detailed usage information, including available options and exit status codes.
Using --help for Executable Programs
Many Linux commands support the --help option, which provides a brief usage guide.
Syntax
command --help
This works for executable programs (e.g., mkdir, cp, ls) but not for shell builtins.
Example: Getting Help on mkdir
mkdir --help
The output typically includes:
Command usage
Available options
Error reporting instructions
Using man for Detailed Manual Pages
Most command-line programs have manual pages (man pages), which serve as formal documentation.
Syntax
man command
This opens the manual page for the specified program.
Example: Viewing the ls Manual Page
man ls
Man pages contain:
Command description
Syntax overview
Detailed options explanation
Exit status codes
Man Page Sections
Linux man pages are categorized into eight sections:
Section | Contents |
1 | User commands |
2 | Programming interfaces for kernel system calls |
3 | Programming interfaces for the C library |
4 | Special files like device nodes and drivers |
5 | File formats |
6 | Games and screen savers |
7 | Miscellaneous documentation |
8 | System administration commands |
Searching Man Pages in a Specific Section
If a search term appears in multiple sections, specify the section number:
man 5 passwd
This opens the file format documentation for /etc/passwd.
Using apropos for Keyword Searches
The apropos command searches man pages for relevant keywords.
Syntax
apropos keyword
Where keyword is the search term.
Example: Searching for Partition-related Commands
apropos partition
Returns matching man pages, including disk partition utilities (fdisk, cfdisk).
Using whatis for One-line Descriptions
The whatis command provides a short description of a command.
Syntax
whatis command
Where command is the program name.
Example: Checking ls Description
whatis ls
Returns:
bash
ls (1) - list directory contents
This confirms that ls belongs to section 1 (user commands).
Using info for Hyperlinked Documentation
The GNU Project offers an alternative to man pages called info, which uses a hyperlinked structure similar to web pages.
Syntax
info command
Opens the info documentation for the specified command.
Example: Viewing coreutils Info Pages
info coreutils
Displays a structured reference covering multiple utilities in GNU Coreutils.
Navigation Commands for info Pages
Command | Action |
? | Show help menu |
Page Up / Backspace | Move to previous page |
Page Down / Space | Move to next page |
n | Go to next section |
p | Go to previous section |
Q | Exit the info page |
Conclusion
Linux offers multiple ways to access documentation, each suited for different use cases:
Use help for built-in shell commands.
Use --help for quick command usage summaries.
Use man for detailed reference manuals.
Use apropos to search related commands.
Use whatis to view one-line command descriptions.
Use info for structured documentation with hyperlinks.