As you already probably know, man is the command line program which is used to display Linux manual pages (manpages) which are program reference documents stored locally.
At its most basic usage, to view a manpage, simply type man followed by the program you want to view the manpage for. The below example opens the manpage for chown.
Some basic movement and search keys (not that there are tons of other keybindings if you enter any man page and hit h):
- ↓, j # moves down one line
- d # moves down half a page
- f # moves down a full page
- G # moves down to the bottom of the document
- ↑, k # moves up one line
- u # moves up half a page
- b # moves up a full page
- g # moves up to the top of the document
- /string # searches forward for string
- /string # searches backward for string
- q # close the manpage
One of the first things that you’ll notice when entering the manpage for chown is in the upper corners, it says CHOWN(1). This is telling you that you are reading the manpage for chown in section 1. chown also has a manpage in section 2, which is accessible with the following command:
man 2 chown
Note that there are 8 different sections, each of which corresponds to a different part of the system:
- General commands
- System calls
- Library functions
- Special files
- File formats
- Games and screensavers
- System administration commands and daemons
Intro has a man page in each section, and is accessible by simply specifying which section man page you want to use:
man 1,2,3,...,8 intro
Two other uses of man have equivalent utilities themselves.
The first one displays a short description from the manpage:
man -f -or- whatis
The second one searches the short description from the manpage for keywords:
man -k -or- apropos
As an example, the whatis command below will tell you the short description for the program zip, while the apropos command will search all the manpages for the keyword zip.
While it may not be precisely proper usage, don’t forget you can use grep to find and search within manpages as well. For example, the below command searches for the case-insensitive keyword, archive in the manpage zip, then prints the line before the keyword match as well as three after the match.
man zip | grep --color=always -B 1 -A 3 archive | less -R
The output looks something like this:
Note that I used –color=always and the -R switch on less to enable color highlighting within less, and used less itself in order to more easily scroll through the matches.
I hoped all this helped you learn more about manpages!