man (display the manual page for a command)
The man command provides access to the system's reference manuals. It is a comprehensive tool for understanding the functionality, syntax, and options of various commands, system calls, and configuration files.
Example 1: Basic Usage
# Display the manual page for the 'ls' command
man ls
Explanation
This command retrieves and displays the complete manual page for the ls command. You can navigate the page using arrow keys and press 'q' to quit.
Example 2: Specifying a Section
# Display the manual page for 'printf' from section 3 (Library Functions)
man 3 printf
Explanation
Manual pages are organized into sections. This example specifically requests the page for the printf C library function from section 3, distinguishing it from the printf shell command in section 1.
Example 3: Searching with a Keyword
# Search for manual pages related to 'network'
man -k network
Explanation
The -k option allows you to search the short descriptions of all manual pages for a specific keyword. It is equivalent to the apropos command and is useful for finding commands when you don't know their exact names.
Example 4: Displaying All Matching Pages
# Display all manual pages for 'passwd', one by one
man -a passwd
Explanation
Some topics, like passwd, exist in multiple manual sections (e.g., the command in section 1 and the file format in section 5). The -a option displays all matching manual pages sequentially.
Example 5: Finding the Location of a Manual Page
# Show the file path of the 'yum' command's manual page
man -w yum
Explanation
This command does not display the manual page itself but prints the location of the source file on the filesystem. This can be useful for debugging or managing documentation files.
Example 6: Viewing a Short Description
# Display a one-line summary for the 'grep' command
man -f grep
Explanation
Using the -f option provides a concise, one-line description of the command, similar to the whatis command. It helps you quickly understand a command's primary function without opening the full manual.
Example 7: Displaying the Manual in a Web Browser
# Format the 'dnf' man page as HTML and open it in a browser (requires browser configuration)
man --html=firefox dnf
Explanation
For better readability, man can format a page into HTML and pipe it to a specified web browser. This presents the information in a more structured and often more user-friendly format.
Example 8: Case-Sensitive Search
# Perform a case-sensitive search for the manual page 'Passwd'
man -I Passwd
Explanation
By default, man searches are not case-sensitive. The -I option enforces case sensitivity, ensuring that the command searches for a page with the exact capitalization specified.
In other UNIX versions, such as Solaris or illumos, the syntax for accessing a specific manual section can differ. For instance, to view the section 3 page for printf, the command would be man -s 3c printf.