Unix: Getting information
Unix has for ages had an embedded help system known as manual pages.
There exists a manual page for every command mentioned in this ebook.
The manual page for a particular command consists of a one line description of the command
(also used by
apropos), a synopsis (summary) of all the variant uses of the command,
a brief description, and a list of all the options the command can take, and how each option modifies the behaviour of the command.
To read the manual page for a particular command, type
For instance, to find out more about the options you may use with the
wc (word count) command, type:
$ man wc
$ whatis wc
gives a short one-line description of the command, but omits any information about options etc.
When you are not sure of the exact name of a command, try:
$ apropos keyword
This command will give you a list of commands with the keyword in their manual page's short description. For example, try typing:
$ apropos copy
Use the manual pages to find information about the
What options should you use to make the
man command produse the
same outout as
Gnu information system
In addition to the manual pages, there is a newer embedded help system known as info. It is part of the Gnu project from the Free Software Foundation.
The gnu information system usually provides more information and better information than manual pages if you're using a variant of Gnu/Linux and FreeBSD. Unlike the manual pages, which displays all information on a topic as a single, long page, the information system is hierarchical, and lets the reader drill down on a subject by selecting sub-topics from a menu.
Now try it out. For example, look at the info page about
$ info grep
To quit info, type the single letter
Unfortunately, the the commands used by
navigate is unlike any other Unix application. Below is a cheat sheet
listing the essential command keys used by the Gnu information
||show help about using info|
||close help window (some systems)|
||close help window (some systems)|
||go to directory (top of all topics)|
||go to top node of current topic|
||go to menu item near cursor (marked with a *)|
||go to named menu item|
||go to previous topic|
||go to next topic|
||go up (to topic above present)|
In the Gnu information system, menu items (shown with a
* character in the left marigin) links topics (nodes)
together. To select a menu item, use the arrow keys to position the
cursor near an menu item, and press
Menu item can also be selected by naming them expliclitly. To try this out, do the following:
$ info info-stnd
m to go to a named menu item. Pay attention
to the area at the bottom of the screen. This is known as the
echo area. The text “Menu item:” should now appear
in the echo area. You can now start typing in the name of the menu item
you're interested in. Type “node ” (notice the
[space] at the end). When you hit
text in the echo area will auto-complete and spell out “Node Commands”.
This is indeed the name of the menu item we're interested in. Your
terminal should now look like the screen dump below.
[Enter] to go to the Node Commands topic
and learn all about the keys to navigate between nodes.
[Delete] keys lets
you page forwards and backwards. They work both within nodes
and between nodes. To read all about a topic, start
at the top and use
[space] to page through it
until you reach the end.
Use the information system to find information about using the
info command. Find out how to search the information
system for specific keywords. Hint: The menu item for searching
is named “Searching Commands”.
What type of command?
In some situations, you may want to find out what type of command is executed when you type in a particular command string. Many of the standard program that is part of the Unix operating system comes in many different types. They share main characteristics, but there are subtle differences between the typess. How can you know what type you'll be using if you invoke the command?
The answer is the to use
This special command will tell you how command would be
interpreted if it is used as a command name.
Examples, followed by a brief explanation:
$ type type type is a shell builtin
type command is one of the commands that are part of the shell.
$ type man man is hashed (/usr/bin/man)
man command is an executable with absolute path
/usr/bin/man. The location of the executable is also hashed
by the shell. That a command is hashed means that the shell,
to speed things up, has remembered where to find it. (If you need,
you can get make the shell forget with the command
$ type ls ls is aliased to `ls $LS_OPTIONS'
ls command is an alias which will invoke some
ls with the shell variable
LS_OPTIONS as its first argument.
(Don't worry about not knowing what a “shell variable” is. They will be described later.)
$ type -a ls ls is aliased to `ls $LS_OPTIONS' ls is /local/gnu/bin/ls ls is /usr/bin/ls
type command with the option
show all alternatives that exist for the
The shell will invoke /local/gnu/bin/ls $LS_OPTIONS (followed
by any arguments you specify on the command line.
The following command will tell you how much memory is available:
$ cat /proc/meminfo MemTotal: 1922436 kB … SwapTotal: 4194296 kB SwapFree: 4194296 kB …
A lot of fields will be listed, but the two most interesting are the four fields show:
- Total usable ram (i.e. physical ram minus a few reserved bits and the kernel binary code.)
- Total amount of physical swap memory.
- Total amount of swap memory free.
||show the manual page for command|
||show a brief one line description of command|
||search for commands with keyword in their short description|
||show how command will be interpreted|
||show all alternatives that exist for command|
||remove command hashes|