The apropos Command

The apropos command displays a list of all topics in the man pages (i.e., the standard manual that is built into Unix-like operating systems ) that are related to the subject of a query.

apropos takes its name from the English word with the same spelling (and the same pronunciation) that means relevant. It is particularly useful when searching for commands without knowing their exact names.

apropos's syntax is:

apropos keywords

A single line is displayed on the monitor screen for each man page that contains one or more of the keyword(s) in its NAME section. The NAME section, which is the minimum required for every man page, consists of a single line containing the page's title (i.e., the name of the command or other topic) and a very brief description.

Each line returned by apropos contains three items about a specific man page: (1) its title (2) its section number (i.e., an integer from one to nine indicating which of the nine standard man sections the page is located in) and (3) the description from its NAME section.

The results for each keyword are listed separately. Thus, for example, if two keywords are used, a list of results for the first keyword is provided first, and this is followed by a list of results for the second keyword. There is no vertical space between the lists.

The lines returned for each keyword are sorted according to the man page titles. All of the titles beginning with an upper case (i.e., capital) letter are listed first and arranged alphabetically, and they are followed by all of the titles beginning with a lower case (i.e., small) letter, which are likewise alphabetized.

A convenient feature of apropos is that it is case insensitive during its search; that is, upper case letters are treated as the same letters as their lower case counterparts. Although Unix-like operating systems are (wisely) case sensitive for almost everything, case insensitive search operations are clearly more efficient for users.

In addition to returning topics that contain a given keyword, apropos also returns any topics whose NAME sections contain longer words that include the keyword. For example, when looking for the word compile, apropos also finds all instances of the words compiler and compiled.

apropos does not actually search the man pages directly, as this could be relatively time consuming. Rather, it searches a database that basically contains just each page's title, section number and description from its NAME section. This database is a text file that is generated by the operating system from the man pages when the apropos command is used for the first time after the operating system has been installed. Its location varies according to the particular system; in the case of Red Hat 9, for example, it is /var/cache/man/whatis.

The following would provide information about the pstree command (which displays the names of the processes currently on the system in the form of a tree diagram):

apropos pstree

A single line of information is returned, and it would look something like: pstree   (1) - display a tree of processes

Because case is ignored by apropos during its search, the same result would be obtained by using all upper case letters or some combination of upper case and lower case letters, for example

apropos PsTree

The number of results returned would be greater if only the first few letters of pstree were used instead of the entire word. For example, the following would produce several additional lines of output because the letters pst are also part of other words in addition to pstree:

apropos pst

As another example, the following command returns information about the editing programs that are available on a system:

apropos editor

apropos often produces much more information than can fit on a single monitor screen. In such case, the output moves very rapidly up the screen and is difficult to read. One way to solve this problem is to pipe (i.e., send) the output to a command such as more or less that displays it one screenful at a time.

For example, using apropos to obtain information about the cat command (which is used to read and combine files) generates a very large amount of output. This is because the string (i.e., sequence of letters) cat is also found in other words that are frequently used in the NAME lines, such as authenticate, catalog, certificate, locate and verification. The following pipeline makes it possible to look at the output page by page, both forward (by pressing the space bar) and backward (by pressing the b key):

apropos cat | less

apropos produces the same result as the man command used with its -k option. The man command followed by a keyword displays the full contents of the man page about that topic (if such topic exists), but when used with its -k option it only shows the name, section number and first line of the page. Thus, for example,

man -k editor

returns the same result as

apropos editor

The whatis command is similar to apropos except that it searches only for whole words that match the keywords, and it ignores parts of longer words that match the keywords. Thus, whatis is particularly useful if it is desired to obtain a brief description only about a specific command whose exact name is already known.

Thus, for example, whatis could be used to obtain the same information about the cat command that apropos provides, but without generating the extensive output about other, irrelevant topics. That is,

whatis cat

The following single line is returned: cat   (1) - concatenate files and print on the standard output

This output contains some of the arcane terminology that is typical of the man pages and other documentation for Unix-like operating systems. concatenate files means to combine the contents of two or more files into a single new file without deleting the originals. Print means to send or to display, and standard output is, by default, the display screen. Such terminology can seem confusing to newcomers, but it typically becomes natural, and even preferred, as users become familiar with it.

Created December 26, 2004.
Copyright © 2004 - 2005 The Linux Information Project. All Rights Reserved.