Bash Manual (man)

Access built-in documentation for commands

📖 What is the man Command?

The man command displays the manual pages for Linux commands. It provides detailed documentation including syntax, options, and examples for any command installed on your system.


# View manual for ls command
man ls

# View manual for grep command
man grep
                                    

Basic man Usage

📄

View Manual

Display command documentation

man command_name
🔍

Search Manual

Find commands by keyword

man -k keyword
📑

Section Number

Access specific manual section

man 5 passwd

Quick Help

Brief command description

whatis command

🔹 Viewing Command Manuals

The man command opens detailed documentation for Linux commands using the less pager interface. Users can scroll with arrow keys, search with /, and quit with q. This primary resource provides comprehensive information about command syntax, options, and examples, serving as the definitive reference for learning and mastering command-line tools.

# View manual for the ls command
man ls

# View manual for the cp command
man cp

# View manual for the find command
man find

Output Example:

LS(1)                    User Commands                   LS(1)

NAME
       ls - list directory contents

SYNOPSIS
       ls [OPTION]... [FILE]...

DESCRIPTION
       List information about the FILEs...

🔹 Searching for Commands

When command names are unknown, man -k or apropos search manual descriptions by keyword. These tools return matching commands based on functionality descriptions, helping users discover appropriate tools for specific tasks. This search capability is invaluable for learning new commands and expanding terminal proficiency through systematic documentation exploration.

# Search for commands related to "copy"
man -k copy

# Search for commands related to "network"
man -k network

# Alternative: use apropos
apropos file

Output:

cp (1)               - copy files and directories
scp (1)              - secure copy (remote file copy)
rsync (1)            - fast remote file copying tool

🔹 Manual Sections

Manual pages are organized into numbered sections covering different documentation categories. Section 1 contains user commands, section 5 covers file formats, and section 8 includes administration commands. Specifying section numbers (e.g., man 5 passwd) accesses specific documentation when multiple entries exist, ensuring users find relevant information efficiently.

Common Manual Sections:

  • 1: User commands (ls, cp, grep)
  • 2: System calls (open, read, write)
  • 3: Library functions (printf, malloc)
  • 5: File formats (passwd, fstab)
  • 8: System administration (mount, useradd)
# View passwd command manual (section 1)
man 1 passwd

# View passwd file format manual (section 5)
man 5 passwd

# View crontab command (section 1)
man 1 crontab

# View crontab file format (section 5)
man 5 crontab

🔹 Quick Command Information

The whatis command provides one-line descriptions without opening full manual pages. This quick reference is ideal when users need brief command reminders or want to verify command purposes rapidly. It's faster than browsing complete documentation and integrates well into learning workflows and quick information retrieval scenarios.

# Get brief description of ls
whatis ls

# Get brief description of grep
whatis grep

# Get brief description of multiple commands
whatis ls cp mv rm

Output:

ls (1)               - list directory contents
cp (1)               - copy files and directories
mv (1)               - move (rename) files
rm (1)               - remove files or directories

🔹 Navigating Manual Pages

Manual pages use the less pager for navigation with specific keyboard commands. Space scrolls down pages, b scrolls up, arrows move line-by-line, and q quits. Search functions (/ forward, ? backward) locate specific text within documentation. Mastering these navigation skills enhances documentation browsing efficiency and learning speed.

Navigation Keys:

  • Space / Page Down: Scroll down one page
  • b / Page Up: Scroll up one page
  • Arrow keys: Move line by line
  • /text: Search forward for "text"
  • n: Next search result
  • q: Quit manual page
  • h: Display help

🔹 Useful man Options

The man command offers several helpful options beyond basic manual viewing. Flags like -a show all matching pages, -w displays manual file paths, and -f provides brief descriptions. These options facilitate efficient documentation exploration and help users locate specific information quickly within comprehensive manual systems.

# Show all manual pages for a command
man -a intro

# Display the path to the manual file
man -w ls

# Show brief description (same as whatis)
man -f grep

# Search for regex pattern in manual names
man -k "^ls"

Output (man -w ls):

/usr/share/man/man1/ls.1.gz

🧠 Test Your Knowledge

Which command searches for commands by keyword?