Linux man command is number one helper to get more detailed information about Linux commands. There are different alternatives like
info but man is de-facto command for help. In this tutorial we will look various usage examples of man command.
View Man Page
Most common usage for man command is listing a command, tool, library usage simply. We will list manual for
ls command like below.
$ man ls
Manual pages are categorized into sections. Each command, tool, library have a section. Categorization is made according to relevance of command, tool, library. Each section have a number from 1 to 9
- Executable programs or shell commands
- System calls (functions provided by the kernel)
- Library calls (functions within program libraries)
- Special files (usually found in /dev)
- File formats and conventions eg /etc/passwd
- Miscellaneous (including macro packages and conventions), e.g. man(7), groff(7)
- System administration commands (usually only for root)
- Kernel routines [Non standard]
View Man Page For Specific Section
Sometimes there may be more than one tutorial about some expression. But those manual sections are different. For example
1 manual with the example below.
$ man 1 printf
List Sections For A Command
We may want to list sections for a command, library or function. We will use man pages file to search and list. In the example we will look
printf command manual pages.
$ man -aw printf
We can get section numbers from file name and directory name.
View All Man Pages For A Command
Another usage form for man pages is viewing all pages in a single command. Manual pages will be printed in a string mode. In order to quit from pages use
q shortcut. We will use
-a option to list all manual pages for
$ man -a printf
View Man Page In Browser
Another useful feature is viewing man pages in a browser. This is more human friendly way to read manuals but keep in mind that this will require GUI desktop. First we will set BROWSER variable for the command line interface bash and than use
-H parameter with related command which is
printf in this situation.
$ export BROWSER=/usr/bin/firefox
$ man -H printf
Search Man Page NAME Section
Man pages have different sections too. These are used to define part names. Here are these sections.
NAMEcontains name of the command and short explanation
SYNOPSIScontains usage syntax
DESCRIPTIONcontains more detailed explanation
OPTIONScontains all options about command
HISTORYcontains history about the command and persons
$ man -f printf
Search Man Page NAME and DESCRIPTION Section
In previous example we have only searched in NAME section. We may want to get more results and search in DESCRIPTION section too. We will provide
-k option like below.
$ man -k printf