man

system managementlinux
The man command is one of the most frequently used commands in Linux/Unix-like operating systems. man The man command is used to display the manual pages (documentation) for commands, utilities, functions, and files in Unix-like operating systems. It provides a standardized way to access comprehensive documentation for almost every command and feature available on the system.

Quick Reference

Command Name:

man

Category:

system management

Platform:

linux

Basic Usage:

man [options] [arguments]

Common Use Cases

  • 1

    Manual pages

    Display manual pages for commands and utilities

  • 2

    Documentation

    Access detailed documentation for installed software

  • 3

    Command reference

    Quickly look up command syntax and options

  • 4

    Learning

    Learn about new commands and utilities

Syntax

man [OPTION]... [SECTION] NAME...

Options

Option Description
-a, --all Display all matching manual pages, not just the first
-d, --debug Display debugging information
-e, --encoding Specify output encoding
-f, --whatis Equivalent to whatis - display a short description
-h, --help Show the help message
-k, --apropos Equivalent to apropos - search for keywords in all pages
-K, --global-apropos Search for text in all manual pages
-l, --local-file Interpret PAGE as a local file name
-m, --systems=SYSTEM Use manual pages from other operating systems
-M, --manpath=PATH Set the search path for manual pages
-p, --preprocessor=STRING Specify preprocessors to run before nroff or troff
-P, --pager=PAGER Specify which pager to use
-r, --prompt=STRING Provide a prompt string for less pager
-s, --sections=LIST Use only these sections (colon-separated)
-t, --troff Format page using troff for printing
-T, --device=DEVICE Set output device for troff
-w, --where, --path, --location Print physical location of manual pages instead of displaying
-W, --where-cat, --location-cat Print physical location of cat files
-c, --catman Used by catman to reformat out of date cat pages
-H, --html=BROWSER Use specified browser for HTML display
-X, --xwindows Use X viewer for HTML display
-Z, --ditroff Format page using ditroff
--usage Print a short usage message
--version Print program version

Examples

How to Use These Examples

The examples below show common ways to use the man command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.

#

Basic Examples:

man ls

Display the manual page for the ls command. This shows the complete documentation, including description, options, examples, and related information for the ls command.

man 5 passwd

Display the manual page for the passwd file format (section 5). This shows documentation about the structure and content of the /etc/passwd file rather than the passwd command, which would be in section 1.

man -k password

Search manual pages for the keyword "password". This is equivalent to the apropos command and helps you find relevant commands or topics when you're not sure of the exact command name.

man -f ls

Display a short description of the ls command. This is equivalent to the whatis command and provides a one-line summary of what the command does.

Advanced Examples:

man -a intro

Display all available intro manual pages from all sections in sequence. The -a option displays all manual pages with the given name, not just the first one found.

man -t ls | lpr

Format the ls manual page as PostScript and send it to the printer. The -t option formats the manual page for printing instead of displaying it in the terminal.

man -H ls

Display the manual page for ls in a web browser. The -H option renders the manual page in HTML format and opens it in the system's default web browser.

man -w ls

Print the location of the ls manual page file without displaying its contents. This is useful for finding where documentation is stored on your system.

LANG=es_ES man ls

Display the Spanish version of the ls manual page if available. This uses the LANG environment variable to specify the preferred language for documentation.

Try It Yourself

Practice makes perfect! The best way to learn is by trying these examples on your own system with real files.

Understanding Syntax

Pay attention to the syntax coloring: commands, options, and file paths are highlighted differently.

Notes

Manual Page Sections:

  • Section 1: Executable programs or shell commands
  • Section 2: System calls (functions provided by the kernel)
  • Section 3: Library calls (functions within program libraries)
  • Section 4: Special files (usually found in /dev)
  • Section 5: File formats and conventions (e.g. /etc/passwd)
  • Section 6: Games
  • Section 7: Miscellaneous (including macro packages and conventions)
  • Section 8: System administration commands (usually only for root)
  • Section 9: Kernel routines (non-standard)

Navigation in Man Pages:

  • Space/Page Down: Forward one page
  • b/Page Up: Backward one page
  • Up Arrow/k: Scroll up one line
  • Down Arrow/j: Scroll down one line
  • g: Go to start of manual page
  • G: Go to end of manual page
  • /pattern: Search for pattern
  • n: Next match in search
  • N: Previous match in search
  • q: Quit
  • h: Display help

How Man Pages Work:

  • Manual pages are written in troff/nroff format with macro packages
  • The man command locates, formats, and displays the requested documentation
  • Most systems use the groff text formatting system to render man pages
  • Man pages are stored in directories like /usr/share/man and /usr/local/man
  • The MANPATH environment variable can be set to specify search locations
  • Pages are compressed to save space but decompressed automatically when viewed

Common Use Cases:

  • Learning how to use a command and its options
  • Finding the correct syntax for a specific operation
  • Discovering alternative commands for a specific task
  • Understanding file formats and system conventions
  • Learning about system calls and library functions (for programmers)
  • Finding detailed information about system administration tasks

Useful Environment Variables:

  • MANPATH: Specifies the directories where man pages are located
  • MANROFFSEQ: Specifies the preprocessors to run before formatting
  • MANWIDTH: Sets the line width for man pages
  • MANPAGER: Specifies the pager program to use for display
  • LANG/LC_MESSAGES: Determines the language for manual pages

Related Commands:

  • info - Alternative documentation system with hypertext capabilities
  • apropos - Search manual pages for a keyword (same as man -k)
  • whatis - Display one-line manual page descriptions (same as man -f)
  • manpath - Determine search path for manual pages
  • less - The default pager used by man on most systems
  • groff - The document formatting system used to process man pages
  • nroff - The text formatter used to generate man page output for terminals

Tips & Tricks

1

Use the -k keyword option to search for keywords in manual pages

2

Use the -f keyword option to search for keywords in manual page names

3

Use the -K keyword option to search for keywords in all manual pages

4

Use the -w option to display the location of the manual page

5

Use the -h option to display help

Common Use Cases

Manual pages

Display manual pages for commands and utilities

Documentation

Access detailed documentation for installed software

Command reference

Quickly look up command syntax and options

Learning

Learn about new commands and utilities

Troubleshooting

Get help with common issues and errors

Related Commands

These commands are frequently used alongside man or serve similar purposes:

Use Cases

1

Manual pages

Display manual pages for commands and utilities

2

Documentation

Access detailed documentation for installed software

3

Command reference

Quickly look up command syntax and options

4

Learning

Learn about new commands and utilities

5

Troubleshooting

Get help with common issues and errors

Learn By Doing

The best way to learn Linux commands is by practicing. Try out these examples in your terminal to build muscle memory and understand how the man command works in different scenarios.

$ man
View All Commands