man
Command: Your Linux Manual
Summary
The man
command is your built-in manual for almost any command on a Linux system. It provides detailed information about commands, including their syntax, options, and examples.
Introduction
The man
command is indispensable for anyone working with Linux. It allows you to quickly access the official documentation for a wide variety of commands and utilities. Think of it as having a comprehensive reference library at your fingertips. If you're ever unsure about how a command works or what options are available, man
is the first place you should look. The manual pages (manpages) are organized into different sections, each covering a specific area. For example, section 1 covers user commands, section 5 covers file formats, and section 8 covers system administration commands.
Use case and Examples
Basic usage
This will display the manual page for thels
command, showing its syntax, options, and a description of its function. Searching for keywords
This searches the manual page descriptions for the word "process" and lists any commands that match. Equivalent toapropos process
. Specifying a manual section
This will display the manual page for thepasswd
file format, which is found in section 5 of the manual. Without specifying the section, man passwd
would show the manual page for the passwd
command. Display manual page from a specific file
If you have a manual page in a file, such as./my_script.1
, you can use man
to display it. Finding all manual pages with a given name
Display all available manual pages of the given name.printf
command can be found in multiple sections. Commonly used flags
Flag | Description | Example |
---|---|---|
-k | Search the manual page names and descriptions for keywords. Equivalent to apropos . | man -k directory (Finds commands related to directories) |
-f | Equivalent to whatis . Shows a very short description from the manual page, if one exists. | man -f ls (Shows the brief description of the ls command) |
-w | Print the pathname of the associated roff source file, instead of formatting the manual page. | man -w ls (Shows the location of the ls.1 manual page source file) |
-a | Display all available manual pages of the given name, in sequence. | man -a printf (Shows manual pages for printf in all sections where it exists) |
-P <pager> | Specify the pager program to use for displaying the manual page. | man -P less ls (Uses the less program to display the manual page for ls ) |
-M <path> | Specify an alternate set of manual page directories to search. | man -M /opt/man ls (Searches for manual pages in the /opt/man directory) |