Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

man Command Guide

man (short for “manual”) displays the user documentation for a command, a configuration file format, or a system call. It’s the built-in documentation browser of Linux: nearly every command you install ships with a man page, and man is how you read it.

What is man, and Why Use It?

You’ve just learned about tar. You want to know exactly what --exclude does, whether it accepts multiple patterns, and what happens with trailing slashes. You could search the web — or you could type:

man tar

and get the authoritative documentation written by the people who built the tool, matching the exact version installed on your system. Man pages cover commands, file formats (/etc/passwd), library functions, and even games.

They’re the first place to look whenever a tool does something surprising.

Reading a Man Page

A man page opens in a pager (usually less):

man ls

Inside the pager:

KeyAction
SpaceScroll down one page
bScroll up one page
/patternSearch forward
n / NNext / previous search hit
G / gJump to end / start
qQuit

If you already know less, you already know man — see the less page for the full keybinding set.

Man Sections: The Same Name Means Different Things

Man pages are grouped into numbered sections, and the same word can have several:

man 1 printf    # the printf command
man 3 printf    # the C library printf() function
man 5 passwd    # the /etc/passwd file format
man 8 ifconfig  # a system administration command

Section conventions:

SectionContents
1User commands (the everyday ones)
2System calls (kernel functions)
3Library functions (C library, etc.)
5File formats and conventions
8System administration commands

If man printf shows you something confusing, you probably landed in the C library section — add the section number to disambiguate.

Searching Across All Manuals

Forgot the command name? Search every manual page’s short description:

# Search descriptions for the keyword "copy"
man -k copy

# One-line description of a specific command
man -f ls
# ls, ls1 (1)  - list directory contents

man -k and man -f are also available as the standalone commands apropos and whatis. Both rely on a prebuilt database; if searches come up empty, see the pitfalls below.

Searching Inside a Man Page

You don’t have to read the whole page — pipe it to grep to jump straight to what you need:

# Find every mention of "color" in the ls manual
man ls | grep -i color

# Show the OPTIONS section and everything after it
man tar | sed -n '/OPTIONS/,$p'

Or just search inside the pager with /pattern, as shown above.

man in Daily Life

A realistic discovery flow:

# Hear about a flag you don't recognize
man df | grep -i filesystem

# Check the exact syntax of a config file format
man 5 fstab

# Find a command that does X
man -k "disk usage"

Common Pitfalls

  • man: command not found. Minimal containers and slim installs often omit the man pages. Install the man-db package (Debian/Ubuntu) or man-db/man (Fedora/Arch) — see the packages section.
  • Stale search database. man -k and whatis use a prebuilt index. After installing software, refresh it with mandb (or makewhatis on some systems) before trusting empty results.
  • Section surprises. man printf, man kill, or man echo may show the C library or file-format page instead of the command. Use man 1 ... to force the command section.
  • Ctrl-S freezes your terminal. In the pager, Ctrl-S is flow control — it looks like a hang. Press Ctrl-Q to unfreeze. (It also disables the feature permanently for your shell session with stty -ixon.)
  • Man pages describe the installed version. If your docs mention a flag your build doesn’t have, check command --version — you may be on an older release.
  • info — the GNU hyperlinked alternative to man
  • less — the pager man uses underneath
  • grep — search within manual pages
  • type — check what a command name is before reading its docs
  • which — find the executable a man page describes

Cheatsheet

CommandWhat it does
man lsRead the manual for ls
man 5 passwdRead a specific man section
man -k copySearch all manual descriptions
man -f lsOne-line description of ls
man ls | grep -i colorSearch inside a page
/pattern then nSearch forward inside the pager
qQuit the pager
mandbRebuild the whatis/apropos database