Linux — Getting Help
One of the most important Linux skills is knowing how to find information about commands you don’t know — or commands you’ve forgotten. Linux has excellent built-in documentation.
–help — Quick Reference
Almost every Linux command accepts --help (or -h):
# Quick flag reference for ls
ls --help
# Usage: ls [OPTION]... [FILE]...
# List information about the FILEs (the current directory by default).
# Sort entries alphabetically if none of -cftuvSUX nor --sort is specified.
#
# 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 ..
# --author with -l, print the author of each file
# -b, --escape print C-style escapes for nongraphic characters
# --block-size=SIZE with -l, scale sizes by SIZE when printing them;
# ...
# Quick reference for tar
tar --help | head -30
# Some commands use -h instead of --help
curl -h | head -20
--help is the fastest way to look up a flag you’ve forgotten. You don’t need internet access or any external tools.
man — The Full Manual
man (manual) opens the full documentation for any command:
# Open the manual for ls
man ls
# Open the manual for grep
man grep
Navigating man Pages
Space or f → Forward one page
b → Back one page
/pattern → Search forward
?pattern → Search backward
n → Next match
N → Previous match
g → Jump to beginning
G → Jump to end
q → Quit
man Page Sections
Man pages are organised into numbered sections:
| Section | Content |
|---|---|
| 1 | User commands (ls, grep, find) |
| 2 | System calls (open(), read(), fork()) |
| 3 | C library functions (printf(), malloc()) |
| 4 | Device files (/dev/null, /dev/sda) |
| 5 | File formats (/etc/passwd, crontab syntax) |
| 6 | Games |
| 7 | Miscellaneous (standards, conventions) |
| 8 | System administration commands (useradd, fdisk) |
# The same name can exist in multiple sections
man 1 printf # printf shell command (section 1)
man 3 printf # printf C function (section 3)
# See all sections for a name
man -a printf # Opens all sections one after another
# Read the passwd FILE FORMAT (section 5), not the passwd COMMAND (section 1)
man 5 passwd
# PASSWD(5) File Formats and Conventions PASSWD(5)
# /etc/passwd — password file
# NAME:PASSWORD:UID:GID:COMMENT:HOME:SHELL
# Read man page for crontab format
man 5 crontab
Searching in man Pages
# Search all man page names and descriptions
man -k "compress"
# bzip2 (1) - a block-sorting file compressor
# gzip (1) - compress or expand files
# xz (1) - Compress or decompress .xz and .lzma files
# zip (1) - package and compress (archive) files
# Open man page for any result
man gzip
whatis — One-Line Description
# Get a one-line description of a command
whatis ls
# ls (1) - list directory contents
whatis grep
# grep (1) - print lines that match patterns
whatis passwd
# passwd (1) - change user password
# passwd (5) - password file
# Check multiple commands at once
whatis cd pwd ls cat grep awk sed
# cd: nothing appropriate. (shell built-in — no man entry)
# pwd (1) - print name of current/working directory
# ls (1) - list directory contents
# cat (1) - concatenate files and print on the standard output
# grep (1) - print lines that match patterns
# awk (1) - pattern scanning and processing language
# sed (1) - stream editor for filtering and transforming text
apropos — Search man Page Descriptions
apropos searches man page descriptions for a keyword — useful when you know what you want to do but not the command name:
# Find commands related to "compress"
apropos compress
# bzip2 (1) - a block-sorting file compressor
# gzip (1) - compress or expand files
# zip (1) - package and compress (archive) files
# xz (1) - Compress or decompress .xz and .lzma files
# Find commands related to "network"
apropos network | head -20
# ifconfig (8) - configure a network interface
# netstat (8) - Print network connections
# ss (8) - another utility to investigate sockets
# Find commands related to "disk"
apropos disk
# df (1) - report file system disk space usage
# du (1) - estimate file space usage
# fdisk (8) - manipulate disk partition table
# Update the man page database (run if apropos/whatis return nothing)
sudo mandb
# Processing manual pages under /usr/share/man...
info — GNU Documentation System
info provides more detailed documentation than man for GNU tools:
# Read info page for ls (part of GNU coreutils)
info ls
# Read info page for bash
info bash
# Navigation in info:
# Arrow keys → Navigate
# Enter → Follow a link
# n → Next node
# p → Previous node
# u → Up to parent node
# l → Go back (like browser back)
# q → Quit
# /pattern → Search
For most everyday use, man is preferred. info is most useful for bash, awk, sed, and GNU tool internals.
tldr — Community Simplified Man Pages
tldr (Too Long; Didn’t Read) provides crowd-sourced examples focused on the most common use cases:
# Install tldr
sudo apt install tldr # Ubuntu/Debian
brew install tldr # macOS
# Update the tldr database
tldr --update
# Get practical examples for tar
tldr tar
# tar
# Archiving utility.
# Often combined with a compression method, such as gzip or bzip2.
#
# - [c]reate an archive and write it to a [f]ile:
# tar cf target.tar file1 file2 file3
#
# - [c]reate a gzipped archive and write it to a [f]ile:
# tar czf target.tar.gz file1 file2 file3
#
# - E[x]tract a (compressed) archive [f]ile into the current directory:
# tar xf source.tar[.gz|.bz2|.xz]
#
# - List the contents of a tar [f]ile:
# tar tf source.tar
tldr grep
# grep
# Find patterns in files using regular expressions.
#
# - Search for a pattern within a file:
# grep "search_pattern" path/to/file
#
# - Search for an exact string (disabling regular expressions):
# grep -F "exact_string" path/to/file
#
# - Search recursively (ignoring non-text files) in current directory:
# grep -rI "search_pattern" .
#
# - Show line number for each match:
# grep -n "search_pattern" path/to/file
tldr is often faster than man for quick reference — the examples cover 90% of everyday use.
type — What is This Command?
# Find out if a command is a builtin, alias, or external
type ls
# ls is aliased to 'ls --color=auto'
type cd
# cd is a shell builtin
type grep
# grep is /usr/bin/grep
type ll
# ll is aliased to 'ls -alh --color=auto'
type python3
# python3 is /usr/bin/python3
# -a shows all definitions
type -a ls
# ls is aliased to 'ls --color=auto'
# ls is /usr/bin/ls
which and command -v — Find Command Location
# Find the full path of a command
which python3
# /usr/bin/python3
which git
# /usr/local/bin/git
which terraform
# /usr/local/bin/terraform
# If not found:
which nonexistent
# (no output)
echo $?
# 1 (exit code 1 = not found)
# POSIX-compatible alternative (works in all shells)
command -v python3
# /usr/bin/python3
command -v nonexistent
# (no output, exit code 1)
Summary: Help Commands
| Command | Use Case |
|---|---|
command --help |
Quick flag reminder |
man command |
Full manual with all options |
man 5 file |
File format documentation |
man -k keyword |
Search man pages by keyword |
whatis command |
One-line description |
apropos keyword |
Find commands by what they do |
tldr command |
Practical examples (most common use cases) |
info command |
GNU-style detailed documentation |
type command |
Is it a builtin, alias, or binary? |
which command |
Full path to the binary |
Key Takeaways
--helpis the fastest way to recall a flag — use it constantlyman lsopens the full manual; navigate with Space,/pattern, andqman 5 passwdreads the file format documentation for/etc/passwdaproposis “reverse man” — search by what you want to do, find the commandtldrgives copy-paste examples — install it on every machine you usetypetells you whether a command is a shell builtin, alias, or external binary
| ← Back to Viewing File Contents | Next → Command History and Shortcuts |