man
man
stands for "manual" and is a command which presents the "man pages" for a particular command.
What are "man pages"? Man pages are text documents that describe the utility or command, what it does, how to use it, and what options are available to use. It is one of the best resources to learn about a given command. The man
command should be your first stop to learn about a new command.
To see the "man pages" for the cat
command, you can run the following.
man cat
You will then be presented with text describing the cat
command and its various options. To scroll down in the presented interface, press the "j" button on your keyboard, or use the down arrow key, or the space bar. To scroll up, press the "k" button or the up arrow key. To quit the man pages, press the "q" button (for quit).
whatis
Closely related to the man
command is the whatis
command, which gives a one-line summary of a command. For instnace, here is the operation of whatis cat
and whatis nano
and whatis vi
and whatis head
[email protected]:[~] $ man -f cat
cat (1p) - concatenate and print files
cat (1) - concatenate files and print on the standard output
[email protected]:[~] $ whatis cat
cat (1p) - concatenate and print files
cat (1) - concatenate files and print on the standard output
[email protected]:[~] $ whatis nano
nano (1) - Nano's ANOther editor, an enhanced free Pico clone
[email protected]:[~] $ whatis vi
vi (1p) - screen-oriented (visual) display editor
vi (1) - Vi IMproved, a programmer's text editor
[email protected]:[~] $ whatis head
head (1p) - copy the first part of files
HEAD (1) - Simple command line user agent
head (1) - output the first part of files
whereis
The whereis
command shows where a program is available. For instance, here is the operation of whereis
for emacs
, vi
, nano
, man
, and cd
.
[email protected]:[data] $ whereis emacs
emacs: /usr/share/emacs
[email protected]:[data] $ whereis vi
vi: /usr/bin/vi /usr/share/man/man1p/vi.1p.gz /usr/share/man/man1/vi.1.gz
[email protected]:[data] $ whereis nano
nano: /usr/bin/nano /usr/share/nano /usr/share/man/man1/nano.1.gz /usr/share/info/nano.info.gz
[email protected]:[data] $ whereis man
man: /usr/bin/man /usr/share/man /usr/share/man/man7/man.7.gz /usr/share/man/man1p/man.1p.gz /usr/share/man/man1/man.1.gz
[email protected]:[data] $ whereis cd
cd: /usr/bin/cd /usr/share/man/man1p/cd.1p.gz /usr/share/man/man1/cd.1.gz
type and which
Another way to check where a command is located is to use type
or which
; see page 36 in Section 2.6 of Unix Power Tools
For instance, we could check:
type cat
and type nano
and type vi
and type head
and in bash
we can type:
type -all cat
and type -all nano
and type -all vi
and type -all head
and
which cat
and which nano
and which vi
and which head