Bash: Getting Help
One of the most important skills in Linux is knowing how to find help. You can't memorize every command and every option. Learning to use man pages, help commands, and online resources will make you self-sufficient and efficient. This lesson teaches you how to help yourself.
What You'll Learn
- Using man pages (manual pages)
- Understanding man page sections
- Command help options (--help, -h)
- Using info pages
- Finding command examples with tldr
- Online resources and communities
- Building your own knowledge base
The Man Command
What Are Man Pages?
man = manual
Comprehensive documentation for:
- Commands
- System calls
- Library functions
- File formats
- Configuration files
Installed locally on every Linux system
Basic Usage:
man command_name
Examples:
man ls
man grep
man chmod
man passwd
Navigating Man Pages
Opening a Man Page:
man ls
Navigation Keys:
Space # Next page
b # Previous page
Enter # Next line
k # Up one line
j # Down one line
g # Go to beginning
G # Go to end
/pattern # Search forward
?pattern # Search backward
n # Next search result
N # Previous search result
q # Quit
h # Help
Example Session:
man grep
# Inside man page:
/regex # Search for "regex"
n # Next occurrence
n # Next occurrence
q # Quit
Understanding Man Page Structure
Typical Sections:
NAME
Command name and brief description
SYNOPSIS
How to use the command (syntax)
DESCRIPTION
Detailed explanation
OPTIONS
All available options/flags
EXAMPLES
Usage examples (if available)
SEE ALSO
Related commands
AUTHOR
Who wrote it
BUGS
Known issues
Reading the SYNOPSIS:
ls [OPTION]... [FILE]...
Syntax:
[] = Optional
... = Can be repeated
| = OR (choose one)
<> = Required (sometimes)
Examples:
ls [OPTION]... [FILE]...
= ls
= ls -l
= ls -lah /etc /var
All valid!
cp [OPTION]... SOURCE DEST
= cp file.txt backup.txt
grep [OPTION]... PATTERN [FILE]...
= grep "error" log.txt
= grep -r "password" /etc
Man Page Sections
The 9 Sections:
1. User commands (programs)
2. System calls (kernel functions)
3. Library functions (C library)
4. Device files
5. File formats and conventions
6. Games
7. Miscellaneous
8. System administration commands
9. Kernel routines
View Specific Section:
# Section 1: passwd command (change password)
man 1 passwd
# Section 5: passwd file format
man 5 passwd
# List all sections with keyword
man -k passwd
# Or: apropos passwd
Why Sections Matter:
# Without section number:
man passwd
# Shows first match (usually section 1)
# With section number:
man 5 passwd
# Shows file format of /etc/passwd
# This matters when multiple entries exist!
Searching Man Pages
Search by Name:
# Find commands with keyword in name
man -k keyword
# Or use apropos (same thing)
apropos keyword
Examples:
man -k network
man -k compress
man -k encrypt
apropos ssh
Search Within Man Page:
# Open man page
man command
# Press / to search
/search_term
# Press n for next occurrence
# Press N for previous occurrence
Search All Man Pages:
# Search descriptions
man -K search_term
# This searches content, not just names
# Can be slow!
Command Help Options
--help Flag:
Most commands support --help:
ls --help
grep --help
chmod --help
nmap --help
Advantages:
- Quick summary
- Doesn't leave terminal
- Shows most common options
Example output:
$ ls --help
Usage: ls [OPTION]... [FILE]...
List information about the FILEs (the current directory by default).
Mandatory arguments to long options are mandatory for short options too.
-a, --all do not ignore entries starting with .
-A, --almost-all do not list implied . and ..
-l use a long listing format
-h, --human-readable with -l, print sizes in human readable format
...
-h Flag:
Some commands use -h instead:
python3 -h
git -h
docker -h
help Command (Bash Builtins):
For shell built-in commands:
help cd
help alias
help export
help source
Built-in vs External:
# Check if command is built-in
type cd
# Output: cd is a shell builtin
type ls
# Output: ls is /usr/bin/ls
# Built-ins use 'help'
# External commands use 'man' or '--help'
Info Pages
What Are Info Pages?
Alternative to man pages
More structured (hyperlinked)
GNU project documentation
More detailed than man pages (sometimes)
Usage:
info command
Examples:
info ls
info grep
info bash
Navigation:
Space # Next page
Backspace # Previous page
n # Next node
p # Previous node
u # Up one level
l # Last visited node
q # Quit
? # Help
When to Use Info:
man page too brief? → Try info
Need comprehensive guide? → info
Want hyperlinked navigation? → info
Most people prefer man pages, but info can be more detailed.
TLDR Pages (Too Long; Didn't Read)
What Is TLDR?
Community-driven simplified man pages
Focuses on practical examples
Quick reference
Easy to read
Installation:
# Node.js version
sudo npm install -g tldr
# Python version
pip3 install tldr
# Rust version (recommended)
cargo install tealdeer
Usage:
tldr command
Examples:
tldr tar
tldr grep
tldr find
tldr nmap
Example output:
$ tldr tar
tar
Archiving utility.
- Create an archive from files:
tar cf target.tar file1 file2 file3
- Extract an archive:
tar xf source.tar
- Extract a gzipped archive:
tar xzf source.tar.gz
- Create a gzipped archive:
tar czf target.tar.gz file1 file2 file3
Update TLDR Cache:
tldr --update
Practical Help Strategies
Strategy 1: Quick Reference
# 1. Try --help first (fast)
command --help
# 2. If not enough, check man page
man command
# 3. Still confused? Check examples
tldr command
# 4. Need more? Search online
Strategy 2: Find the Right Command
# Don't know the command?
# Search by keyword
man -k network
man -k copy
man -k archive
apropos encrypt
Strategy 3: Learn by Example
# Find examples in man page
man grep
# Press /
# Type: EXAMPLE
# Press n to find examples section
# Or use tldr for instant examples
tldr grep
Online Resources
Official Documentation:
Linux man pages online:
https://man7.org/linux/man-pages/
GNU Manuals:
https://www.gnu.org/manual/
The Linux Documentation Project:
https://tldp.org/
Interactive Help:
ExplainShell:
https://explainshell.com/
Paste command → Get explanation of each part
Example: https://explainshell.com/explain?cmd=tar+xzvf+file.tar.gz
Command Cheat Sheets:
DevHints:
https://devhints.io/
Cheat.sh (CLI):
curl cheat.sh/command
Example:
curl cheat.sh/tar
curl cheat.sh/grep
Q&A Communities:
Stack Overflow:
https://stackoverflow.com/questions/tagged/bash
Unix & Linux Stack Exchange:
https://unix.stackexchange.com/
Reddit:
r/linux4noobs
r/commandline
Building Your Knowledge Base
Create Personal Cheat Sheets:
# Create notes directory
mkdir -p ~/notes
# Create command cheat sheet
nano ~/notes/commands.md
# Add commands you use frequently
# Example:
# find . -name "*.txt" # Find all txt files
# grep -r "pattern" /path # Recursive grep
Command History:
# View recent commands
history | tail -20
# Search history
history | grep nmap
# Save important commands
history | grep nmap >> ~/notes/nmap-commands.txt
Alias for Quick Notes:
Add to ~/.bashrc:
alias note='nano ~/notes/commands.md'
alias notes='cat ~/notes/commands.md'
Reload:
source ~/.bashrc
Usage:
# Add note
note
# View notes
notes
Practical Exercises
Exercise 1: Man Pages
# 1. Read the man page for 'ls'
man ls
# 2. Search for "sort" within the page
/sort
# 3. Find all commands related to "compress"
man -k compress
# 4. View the passwd file format
man 5 passwd
# 5. Compare with passwd command
man 1 passwd
Exercise 2: Command Help
# Try --help on various commands
grep --help
find --help
tar --help
ssh --help
# For built-ins, use help
help cd
help alias
help export
Exercise 3: TLDR Pages
# Install tldr
sudo npm install -g tldr
# Or: pip3 install tldr
# Try it
tldr tar
tldr find
tldr rsync
tldr curl
Exercise 4: Find Unknown Commands
# Scenario: Need to change file permissions
man -k permission
# Scenario: Need to archive files
man -k archive
# Scenario: Need to monitor network
man -k network | grep monitor
Common Help Scenarios
Scenario 1: "How do I use this command?"
# Quick summary
command --help
# Detailed info
man command
# Examples
tldr command
Scenario 2: "What does this option do?"
# Search in man page
man command
/option_name
# Example: What does grep -r do?
man grep
/-r
Scenario 3: "What command do I need?"
# Search by keyword
man -k keyword
apropos keyword
# Example: Need to find files
man -k find
Scenario 4: "I saw a command but forgot it"
# Check history
history | grep partial_command
# Or search all commands
compgen -c | grep partial
Tips for Effective Learning
1. Read Man Pages Actively:
Don't just skim!
- Try examples as you read
- Experiment with options
- Take notes
2. Focus on Common Options:
Don't memorize everything!
Focus on:
- Most frequently used options
- Options relevant to your work
- Building blocks (grep, find, etc.)
3. Learn By Doing:
Best way to learn:
1. Have a problem
2. Look up solution
3. Try it
4. Understand what happened
5. Repeat
4. Build Mental Models:
Don't just memorize commands
Understand:
- What problem does it solve?
- How does it work?
- When should I use it?
Quick Reference
Getting Help:
man command # Full manual
command --help # Quick help
help command # For built-ins
info command # GNU info pages
tldr command # Simple examples
Searching:
man -k keyword # Search by keyword
apropos keyword # Same as man -k
man -K pattern # Search all content
/pattern # Search within man page
Man Page Sections:
man 1 cmd # User commands
man 5 file # File formats
man 8 cmd # Admin commands
Navigation (in man):
Space # Next page
q # Quit
/pattern # Search forward
n # Next result
Online:
https://explainshell.com
curl cheat.sh/command
https://man7.org/linux/man-pages/
Resources
Local Help:
man man # Manual for man command
man intro # Introduction to commands
man hier # Filesystem hierarchy
Online:
- ExplainShell: https://explainshell.com
- Cheat.sh: https://cheat.sh
- TLDR Pages: https://tldr.sh
- Man7.org: https://man7.org/linux/man-pages/
Books:
- The Linux Command Line by William Shotts
- Linux Pocket Guide by Daniel Barrett
Next Steps
- Practice reading man pages daily
- Install tldr for quick references
- Create personal cheat sheets for commands you use
- Use ExplainShell for complex commands
- Build the habit of looking things up instead of guessing!
Remember: Even expert Linux users constantly reference documentation. Knowing how to find help is more important than memorizing everything!
"RTFM: Read The Fine Manual (and man pages are fine indeed)."