Americas

  • United States
sandra_henrystocker
Unix Dweeb

Using the apropos command on Linux

How-To
Apr 24, 20243 mins
Linux
Programmer sitting at the desk in his office and trying to solve problem of new code.
Credit: Shutterstock

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.

sandra_henrystocker
Unix Dweeb

Sandra Henry-Stocker has been administering Unix systems for more than 30 years. She describes herself as "USL" (Unix as a second language) but remembers enough English to write books and buy groceries. She lives in the mountains in Virginia where, when not working with or writing about Unix, she's chasing the bears away from her bird feeders.

The opinions expressed in this blog are those of Sandra Henry-Stocker and do not necessarily represent those of IDG Communications, Inc., its parent, subsidiary or affiliated companies.

More from this author