Skip to Main Content
 

Major Digest Home Using the apropos command on Linux - Major Digest

Using the apropos command on Linux

Using the apropos command on Linux

The word apropos means “fitting and to the point”. As a command on a Linux system, its role is to identify commands that relate to the particular terms that you are asking about – such as files, lists, disks, dates users, accounts, file systems, and a huge pile of other things.

What the apropos command does with the terms you add as arguments is pull the description lines from the top of the related man pages that include them. For example, if you were to ask about “updatedb”, you would see something like this:

# apropos updatedb
updatedb.conf (5)    - a configuration file for updatedb(8)
updatedb (8)         - update a database for plocate

In the example above, apropos found two man pages including the command “updatedb” in the description. Note that the related man -k command does the very same thing.

# man -k updatedb
updatedb.conf (5)    - a configuration file for updatedb(8)
updatedb (8)         - update a database for plocate

In the following example, I searched on the word “halt” and found a series of related commands.

# apropos halt
halt (8)             - Power off, reboot, or halt the machine
poweroff (8)         - Power off, reboot, or halt the machine
reboot (8)           - Power off, reboot, or halt the machine
shutdown (8)         - Halt, power off or reboot the machine
systemd-halt.service (8) - System shutdown logic

Here’s an interesting set of commands that suggest that apropos may sometimes find more than you want to see. I searched on the term “host” and noticed that some of the returned descriptions included “ghost” instead of “host”. Whenever this kind of problem pops up, add the -e option to get an exact (whole word) match. Notice the difference in the response when I use this option. The second command below only counts commands when the description includes “host” as a complete word.

$ apropos host | wc -l
142
$ apropos -e host | wc -l
78

One of the problems you might encounter is when the apropos command responds with “nothing appropriate” regardless of what term you ask about. This means that man pages need to be created or updated.

You should run the mandb command as root to create or update the manual page index caches on your system. The caches will contain information relevant to the current state of the man pages system. This command should fix the problem. Here’s an earlier post about the apropos command and the “nothing appropriate” problem: Using the Linux apropos command – even if you have to fix it first

Note, however, that “nothing appropriate” is not a problem unless you get this response every time you use the apropos or man -k command. As you can see from the command shown below, you’re unlikely to find a man page that deals with hyenas, so you should expect “nothing appropriate”.

$ apropos hyenas
hyenas: nothing appropriate.

Wrap-up

The apropos command can be very handy for finding commands that relate to some command you hope to identify or problem you’re trying to resolve. The command output is also very useful because you might learn about many commands you’ve never before known about or tried. Some of the short descriptions might encourage you to read the full man pages and learn more about the options those commands offer.

Source:
Published: