2024-03-01
The man command’s primary function is simple: display the manual page for a specified command. Let’s start with a basic example:
man lsThis command will display the manual page for the ls command (used for listing directory contents). You’ll notice a wealth of information:
Navigating the manual page is straightforward. Use the spacebar to scroll down, b to scroll up, and Enter to move down line by line. To exit, press q.
Manual pages can be extensive. To efficiently locate specific information, use the / (forward slash) key to initiate a search. For instance, to find information about the -l option within the ls manual page:
man ls
/ -lThis will highlight all occurrences of -l within the manual. Use n to move to the next occurrence.
Manual pages are categorized into sections. For instance, section 1 typically contains commands, section 2 system calls, section 3 library functions, and so on. If multiple manual pages exist for the same name (e.g., a command and a library function), you can specify the section:
man 2 open # Manual page for the 'open' system call (section 2)
man 3 printf # Manual page for the 'printf' library function (section 3)apropos for Keyword SearchesWhen you don’t know the exact command name, apropos is invaluable. It searches the manual page descriptions for a given keyword:
apropos "network configuration"This will list commands related to network configuration, along with a short description.
man Usage: WhatisFor a quick overview, use whatis:
whatis lsThis provides a concise summary of the command’s purpose.
Long manual pages can be overwhelming. You can pipe the output to a pager like less for better navigation:
man ls | lessThis allows you to search, scroll, and navigate the manual page more conveniently within the less utility.
man with Specific Filesman is not limited to commands. You can use it to view other documentation:
man /etc/passwd # View the manual page for the `/etc/passwd` file (if available)This will show you the documentation associated with that specific file, if available. This is less common but handy for system files with associated documentation.