E-Mail:
Get our new Windows 7 eBook (PDF) for $7 with 70+ Tips. Download Now!

Learning about Commands, Part II

  • No Related Post

Learning about Commands, Part II

In addition to man and info, there are two other major
commands that will give you information about the tools available
in your Linux toolbox. whatis
gives you a short blurb explaining what a command is used for, and
apropos finds searches for
commands whose descriptions contain the keyword you specify. Let’s
start with whatis, since
ultimately this command is responsible for making both itself and
apropos work.

The whatis command works as
follows. You feed it a command - for example, let’s say ifconfig - and whatis looks in its database for the listing
corresponding to this command. In the case of ifconfig, I get:

$ whatis ifconfig
ifconfig             (8) - configure a network interface

Whenever you install new programs, you’re adding new commands,
man pages, and more. The
whatis database has to be
refreshed if it’s going to reflect this new information, so many
distributions update it by default on a regular basis. You can run
this update manually at any time by typing (as the root user):

/usr/sbin/makewhatis

The apropos tool is, in a
way, the opposite of whatis.
With whatis, you have to know
the name of the command you’re looking for. With apropos, you don’t know the name of
the command, and use keywords to try to find it. Case isn’t
important here; apropos
ignores whether things are in upper or lower case. Say that you
want to find all of the instant messaging clients installed on
your system. You might try something like:

$ apropos instant
Gaim v0.59.8 [gaim]  (1)  - Instant Messaging client
XRegisterIMInstantiateCallback [XOpenIM] (3x)  - open, close, and otain input method information
XUnregisterIMInstantiateCallback [XOpenIM] (3x)  - open, close, and otain input
method information

Gaim is indeed the instant messaging client I use on my system.
The other stuff… well… those are programming-related items. I
can tell by the (3x) part of
the listing, or really just the number 3. To understand this item, you’ll have to wait until
next week, when we take a brief detour into how man pages are organized. Before I go for this
week, though, I’ll point out one more thing. You’ll want to
usually “pipe” the output from the apropos command to the more command, so you can see only one page at a time.
Otherwise, you’ll watch in horror as pages and pages of output
scroll past you!

You can do this using the pipe symbol: |. This symbol tells Linux
to take the output from the command on its left, and send it as
input to the command on its right. Try this example on your own
machine:

apropos pdf | more

Next week: How man pages are organized …

What Do You Think?

 
35 queries / 0.429 seconds.