If I had to pick the single command that’s saved me the most hours over the years, it wouldn’t be anything flashy — it would be man. Long before Stack Overflow, long before AI assistants, the manual page system was how Unix and Linux documented themselves, and it’s still the most authoritative, always-available, no-internet-required source of truth for how a command actually behaves on the specific system in front of you. I want to walk through man properly here: not just “type man ls,” but the structure of manual pages, the sections, navigation, search, formatting internals, and how to keep the whole system healthy.
What man Is
man is the interface to the Unix/Linux manual page system — a structured, sectioned collection of reference documentation stored on disk and rendered on demand in your terminal. Manual pages are written in a markup language (traditionally troff/groff macros, specifically the man or mdoc macro package) and stored, usually gzip-compressed, under directories like /usr/share/man/.
Basic usage:
man [section] page_name
I tested this directly:
$ 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).
Sort entries alphabetically if none of -cftuvSUX nor --sort is speci-
fied.
The Structure of a Manual Page
Every man page follows a broadly consistent layout, and once you internalize it, you can navigate any page — even for a command you’ve never seen — without reading it top to bottom:
- NAME — the one-line summary (this is exactly what
whatisdisplays) - SYNOPSIS — the formal syntax, showing required and optional arguments
- DESCRIPTION — the full prose explanation of what the command does
- OPTIONS — a breakdown of every flag/switch, usually the section I jump to first
- EXAMPLES — sample invocations, when the page author bothered to include them
- FILES — configuration files or paths the command reads/writes
- ENVIRONMENT — environment variables that affect behavior
- EXIT STATUS — meaning of return codes
- SEE ALSO — cross-references to related commands and files
- BUGS / AUTHOR / COPYRIGHT — closing metadata
Not every page has every section — a simple utility might skip FILES and ENVIRONMENT entirely, while something like bash(1) has dozens of sections because the shell itself is enormous.
Man Page Sections (The Numbers That Matter)
This is the part most people never learn properly, and it genuinely matters. Manual pages are divided into numbered sections by category of thing being documented, not by topic:
| Section | Contents |
|---|---|
| 1 | User commands (executable programs or shell commands) |
| 2 | System calls (functions provided by the kernel) |
| 3 | Library calls (functions within program libraries) |
| 4 | Special files (usually found in /dev) |
| 5 | File formats and conventions (e.g. /etc/passwd) |
| 6 | Games |
| 7 | Miscellaneous (macro packages, conventions, protocols) |
| 8 | System administration commands (usually root-only) |
This numbering is exactly why you sometimes see references like crontab(5) versus crontab(1) — same name, completely different document. I confirmed the practical effect of this directly:
$ man -f passwd
passwd (1) - change user password
passwd (5) - the password file
To specify a section explicitly, put the number before the name:
$ man 5 passwd # the file format documentation
$ man 1 passwd # the command documentation (this is the default if you omit the number)
By default, man searches sections in a fixed order and shows you the first match — usually section 1 — unless you specify otherwise.
Navigating Inside a Man Page
Man pages are displayed through a pager, almost always less on modern systems. That means every less keybinding applies:
| Key | Action |
|---|---|
Space / f | Page down |
b | Page up |
/pattern | Search forward for a pattern |
?pattern | Search backward |
n | Repeat last search, same direction |
N | Repeat last search, opposite direction |
g | Jump to top of the page |
G | Jump to bottom of the page |
q | Quit |
I use / constantly — for anything longer than ls, scanning visually is slower than jumping straight to the flag I need. For example, inside man bash, searching /PROMPTING jumps straight to the prompt customization section instead of scrolling through thousands of lines.
Key Command-Line Options for man Itself
| Option | Description |
|---|---|
-k keyword | Same as running apropos — search descriptions for a keyword |
-f name | Same as running whatis — show the one-line description |
-a | Show all matching manual pages across all sections, one after another |
-w | Print the file path(s) of the man page instead of displaying it |
-M path | Use an alternate manual page directory tree |
-L locale | Force a specific language/locale for the page |
-P pager | Use a specific pager instead of the default |
Finding Every Match Across Sections with -a
$ man -a passwd
This shows section 1’s passwd first; when you q out, it automatically shows section 5’s passwd next. Handy when you’re not sure which one you need and want to skim both.
Locating the Actual File on Disk with -w
$ man -w ls
/usr/share/man/man1/ls.1.gz
I use this when scripting or debugging documentation issues — it confirms exactly which file man is reading, which matters when multiple versions of documentation exist across MANPATH (common if you’ve compiled software from source into /usr/local alongside a distro package in /usr).
Using a Different Pager
$ man -P cat ls | grep -A5 "^OPTIONS"
Piping through cat instead of less is a neat trick for scripting — it lets you grep or process man page content programmatically instead of interactively paging through it.
How man Works Internally
It’s worth understanding the pipeline because it explains a lot of behavior that otherwise looks mysterious:
manresolves the page name againstMANPATH, an ordered list of directories (view yours with themanpathcommand). Default paths typically include/usr/share/man,/usr/local/share/man, and sometimes/opt/*/mandepending on what’s installed.- Within each
MANPATHentry, subdirectories are organized by section —man1/,man5/,man8/, and so on — and often further by locale (man1/ls.1.gzvs. a translatedfr/man1/ls.1.gz). - The page file itself is typically gzip-compressed troff source, using either the classic
manmacro package or the newermdocpackage (more common in BSD-derived tooling). mandecompresses the file and pipes it throughgroff(or historicallynroff) with the appropriate macro package, which renders the troff markup into formatted plain text suitable for a terminal — this is where bold headers, indented option lists, and justified paragraphs come from.- The rendered output is piped into a pager (
lessby default) for interactive display. - A parallel system,
man-db‘s index database, is what powerswhatisandapropos— it’s built by scanning every page’s NAME section with themandbcommand and caching it for instant lookup, completely separate from the rendering pipeline above.
This is also why man can be slow the very first time you view a particular page right after installation on some systems (decompression + groff rendering), but effectively instant afterward if your system caches formatted output (cat pages), a feature some distros enable and others don’t.
Configuration Files
/etc/manpath.config— defines the search path, section order, and mappings between$PATHdirectories and their corresponding man directories. This is the file to edit if you’ve installed software in a nonstandard location and wantmanto find its documentation automatically.~/.manpath— a per-user override, less commonly used.MANPATHenvironment variable — if set, this takes precedence over the configuration file entirely.MANSECTenvironment variable — controls the default order sections are searched in.MANWIDTH/MANPAGER— override output width and pager on a per-session basis.
Example: forcing a specific pager for one command without changing your global config:
$ MANPAGER=cat man ls | head -20
Environment Variables That Affect man
| Variable | Effect |
|---|---|
MANPATH | Overrides the default search path entirely |
MANSECT | Colon-separated list controlling section search order |
MANWIDTH | Forces output to a specific line width regardless of terminal size |
MANPAGER | Overrides the pager used for display |
LANG / LC_ALL | Determines which localized translation of a page is preferred, if available |
Practical Sysadmin Use Cases
Confirming exact option behavior before running a destructive command. I never run find ... -exec rm {} \; variants against production without re-checking man find‘s EXPRESSION section first — the difference between -exec cmd {} \; and -exec cmd {} + genuinely matters for performance and correctness, and it’s easy to misremember.
Reading file format documentation for configs I rarely touch. man 5 crontab, man 5 fstab, man 5 sudoers — these are the authoritative syntax references, more reliable than a random blog post that might be describing a different distro’s defaults.
Checking exit status meanings for scripting. Many man pages include an EXIT STATUS section documenting what each numeric return code means — essential when writing robust error handling in scripts that call external tools.
Scripted documentation grepping. Combined with -P cat, you can pull specific sections programmatically:
man -P cat tar | sed -n '/^OPTIONS/,/^EXAMPLES/p'
Troubleshooting
“No manual entry for X”:
- Confirm the package that provides
Xis actually installed and that it ships documentation — some minimal container/cloud images explicitly strip/usr/share/man/*via dpkg path-exclusion rules to save space. - Check whether
man-dbitself is installed; without it,manmay be entirely absent or replaced with a stub. - Rebuild the index with
sudo mandbif the page exists on disk butman/whatis/aproposcan’t find it.
Man pages display with garbled formatting or literal escape codes: Usually a terminal/locale mismatch, or a broken groff installation. Try forcing a plain ASCII locale: LC_ALL=C man ls.
Wrong version of documentation showing up: If you’ve built software from source and installed it into /usr/local, and an older packaged version also exists in /usr, MANPATH ordering determines which wins. Check with man -w command to see exactly which file is being loaded, and adjust /etc/manpath.config or MANPATH if needed.
Best Practices
- Always check
man command | lessfor anything destructive before running it unfamiliar —dd,find -exec,rm,chmod -R, anything that operates recursively or irreversibly. - Learn to search within a page (
/pattern) rather than scrolling — it’s dramatically faster for large pages likebash(1)oropenssl(1). - Know your section numbers, especially the 1 vs. 5 vs. 8 distinction — it resolves a lot of “why does this documentation not match what I’m seeing” confusion.
- On servers you provision, don’t assume man pages are present — verify and install the relevant manpages package explicitly if your team relies on them.
man vs. info vs. –help
Quick comparison since these three overlap in purpose:
| Tool | Depth | Format | Best for |
|---|---|---|---|
--help flag | Shallow | Terse flag list | Quick reminder of exact flag syntax |
man | Deep | Structured, sectioned prose | Full reference documentation |
info | Deepest (for GNU tools) | Hyperlinked, node-based | Long-form GNU documentation with cross-references |
I usually reach for --help first for a quick flag check, man when I need real explanation, and info specifically for GNU core utilities where the info manual is genuinely more thorough than the man page (coreutils is the classic example).
Compatibility Across Distributions
The man command and the underlying man-db project are standard across essentially all mainstream Linux distributions — Ubuntu, Debian, Fedora, RHEL/CentOS/Rocky, Arch, openSUSE. Some older or more minimal systems use mandoc instead of man-db as the implementation, which is common on BSDs and some embedded Linux setups; behavior is largely compatible for standard usage but some advanced man-db-specific options (like the index-based -k/-f) may differ slightly. Whether documentation ships by default varies more than the tool itself — cloud and container base images frequently strip man pages to reduce size, while traditional server and desktop installs keep them.
Summary
man is the backbone of Linux’s built-in documentation system: structured, sectioned, and locally available without needing the internet. Understanding the section numbering (1 for commands, 5 for file formats, 8 for admin tools, and so on), knowing how to navigate and search within a page via less, and understanding the underlying MANPATH/mandb machinery turns man from “that thing I glance at” into a genuinely fast, reliable reference tool — often faster than searching the web, and always accurate for the exact version installed on your system.
References
man man— the man page for man itself, genuinely worth reading once- man-db project — https://gitlab.com/man-db/man-db
man man-pages— conventions used for writing manual pages- GNU groff documentation — https://www.gnu.org/software/groff/
