My-Tiny.Net :: Networking with Virtual Machines
Using the man Pages
While we prefer to use our menu-driven tools, sometimes we just have to use the command line. However, instead of trying to remember everything, just remember you can easily look stuff up in the man pages.
First, an Important TipJust typing a command and [Enter] has unpredictable results: the command may execute and do something you don't want, or it may present a short list of options. Much better to try the command with--help which will normally display the options list. If the
list is long, use --help 2>&1 |less so you can use the arrow keys to
scroll up and down, and q to quit. Another common option is
--version .
|
The manual pages explain every command available on the system including what they do and the command line arguments they accept. Some can be a little bit difficult to get your mind around, but they are fairly consistent in their structure so once you get used to them it's not so bad.
To see the man page for the whereis command for example, just type
man whereis
and start reading. Type q
to quit.
The sections we see in most of the man pages are (not necessary all or in the same order):
NAME: One line answer about what this command do.
SYNOPSIS: Gives syntax and what available options for a given command
DESCRIPTION: A brief intro about the command
OPTIONS: A description for each option that command have
EXAMPLES or NOTES: Self explanatory.
ENVIRONMENT: Aspects of your shell that could be affected by the command, or variables that will be used.
FILES: Files associated with this command.
EXIT VALUES: Exit values when executing this command.
AUTHORS: the people who created or assisted in the creation of the command.
SEE ALSO: Other commands, tools or working aspects that are related to this command.
BUGS: usually just some known limitations
Always read the DESCRIPTION before starting. You will most probably find interesting info about the aspects you want in the OPTIONS: and EXAMPLES section. For example,
man whereis
tells us to use:
whereis -b command |
to list only the binary files for that command |
whereis -m command |
to list only the man pages for that command |
If you want to search within a page, just use
/
followed by the term you would like to search for and hit enter
If the term appears multiple times you can cycle through them by pressing n
for next.
The man pages as a whole are organized into sections, each containing pages about a specific category of topics as shown below. The section is in parenthesis in the top line, before the NAME: use
man man
to
see the list of sections.
While we are with
man man
we should note that
man -k
and man -f
use apropos
which does not work on our TinyNet machines (sadface). Doesn't
matter though, we can use whereis -m
instead, and
man -w
to show the search path if we are having problems
getting the page to display. Also, if we know where it is, we can
just navigate there with mc
and use [F3]
to view the page.
Some commands will have multiple pages, depending on context. For instance, the
passwd
command has two pages, one in section 1 (user commands) that describes the command line options etc. for the command in user management and another in section 5 that describes the format of the
/etc/passwd file. Generally, the most commonly used topic is displayed
by default, and there are references to any other topics with the same name in
the SEE ALSO section. To choose a page in a specific section just put it in the command, like man 5 passwd
to see the file format page.
A lot of command options have both a long and short version. By convention, the short version starts with a single dash ( - ) while the long version starts with two dashes ( -- ). The big difference is that when we use a single dash we can put the the letters for several options together after the dash, like
netstat -tulp
or
chmod -R a+rwxt /var/run
(check the man pages!) which saves
some typing. The long options are nice for scripts, where we only have to
type things once and probably want to remember what the options are without
having to poke through the man page again.
So, have a look at
man ls
and play with some of the
command line options you find there. Make sure you play with a few as
combinations. Also make sure you play with ls using both absolute and
relative paths.