Lesson 5: Getting Help
Goal: Learn to find documentation and help for any Linux command — without leaving the terminal.
Table of Contents
- Manual Pages — man
- Quick Description — whatis
- The --help Flag
- Find Commands — which & whereis
- Search Manuals — apropos
- Info Pages — info
- Exercises
Manual Pages — man
man (manual) is the most comprehensive help system in Linux. Almost every command has a manual page.
Open a manual page
man ls
Navigation (same as less)
| Key | Action |
|---|---|
Space |
Next page |
b |
Previous page |
/pattern |
Search |
n |
Next search result |
q |
Quit |
Man page structure
NAME — Command name and short description
SYNOPSIS — How to use the command (syntax)
DESCRIPTION — Detailed explanation
OPTIONS — All available flags
EXAMPLES — Usage examples (not always present)
SEE ALSO — Related commands
Reading the SYNOPSIS
ls [OPTION]... [FILE]...
ls— the command[OPTION]— optional flags (square brackets = optional)...— can be repeated[FILE]— optional file argument
Man page sections
There are 9 sections of manual pages:
| Section | Content |
|---|---|
| 1 | User commands |
| 2 | System calls |
| 3 | Library functions |
| 4 | Device files |
| 5 | File formats |
| 6 | Games |
| 7 | Miscellaneous |
| 8 | System admin commands |
| 9 | Kernel routines |
Some names exist in multiple sections:
# passwd the command (section 1)
man 1 passwd
# passwd the file format (section 5)
man 5 passwd
Practical examples
man cp # How to copy files
man chmod # How to change permissions
man crontab # How to schedule tasks
man ssh # How to connect remotely
Quick Description — whatis
whatis gives a one-line description of a command.
whatis ls
Output:
ls (1) - list directory contents
whatis chmod cp mv rm
Output:
chmod (1) - change file mode bits
cp (1) - copy files and directories
mv (1) - move (rename) files
rm (1) - remove files or directories
This is perfect when you know the command but forgot what it does.
The --help Flag
Almost every command supports --help for a quick reference.
ls --help
cp --help
mkdir --help
This is shorter than the full man page and shows the most common options.
Some commands use -h
tar -h
git commit -h
Find Commands — which & whereis
which — Where is the binary?
which shows the full path of a command's executable.
which python3
Output:
/usr/bin/python3
which ls
# Output: /usr/bin/ls
which nano
# Output: /usr/bin/nano
which node
# Output: /usr/local/bin/node
Check if a command exists
which docker
# If no output → docker is not installed
which nonexistent-command
# No output = not found
whereis — Find binary, source, and man pages
whereis ls
Output:
ls: /usr/bin/ls /usr/share/man/man1/ls.1.gz
whereis python3
Output:
python3: /usr/bin/python3 /usr/lib/python3 /usr/share/man/man1/python3.1.gz
whereis shows:
- The binary location
- The source files (if available)
- The man page location
Search Manuals — apropos
apropos searches all man page descriptions for a keyword. Use it when you don't know the command name.
apropos "copy files"
Output:
cp (1) - copy files and directories
install (1) - copy files and set attributes
apropos disk
Output:
df (1) - report file system disk space usage
du (1) - estimate file space usage
fdisk (8) - manipulate disk partition table
apropos "network interface"
Update the database
If apropos returns nothing, update the database:
sudo mandb
Info Pages — info
Some GNU programs have more detailed documentation in info format.
info coreutils
info grep
Navigation in info
| Key | Action |
|---|---|
Space |
Next page |
Backspace |
Previous page |
n |
Next node |
p |
Previous node |
u |
Up one level |
Enter |
Follow link |
q |
Quit |
For most daily use, man and --help are sufficient.
Exercises
Exercise 1: Explore man pages
# 1. Look up the tar command
man tar
# Find the flag for extracting files (hint: search for "extract")
# 2. Look up chmod
man chmod
# Find the section about octal notation
# 3. Quick lookup
whatis tar chmod grep find
Exercise 2: Find commands
# 1. Where is the bash binary?
which bash
# 2. Find everything related to python
whereis python3
# 3. Find commands related to "compress"
apropos compress
# 4. Find commands related to "network"
apropos network
Exercise 3: Self-help
# 1. Check the help for the 'find' command
find --help
# 2. Check the help for 'grep'
grep --help
# 3. What does 'tee' do?
whatis tee
# 4. Read the man page for a command you've never used
man xargs
Key Takeaways
man command— full documentation (your primary resource)whatis command— one-line descriptioncommand --help— quick reference of optionswhich command— find where a command liveswhereis command— find binary, source, and man pagesapropos keyword— search for commands by description- When in doubt:
manis your best friend
Next Lesson: Lesson 6: Input & Output — echo →