The apropos
command is used to search for a specific string in the whatis database. The whatis database is a collection of short descriptions for Unix commands and functions. The apropos
command searches through these descriptions and returns a list of commands and functions that match the search string.
Overview
The basic syntax for the apropos
command is as follows:
apropos [options] search_string
Here, search_string
is the string that you want to search for in the whatis database. The apropos
command will search for this string in the short descriptions of all Unix commands and functions.
For example, if you want to search for all commands related to the string “network”, you can use the following command:
apropos network
This will return a list of all commands and functions that have the word “network” in their short description.
You can also use regular expressions in your search string. For example, if you want to search for all commands related to networking that start with the letter “n”, you can use the following command:
apropos '^n.*network'
This will return a list of all commands and functions that have a short description starting with the letter “n” and containing the word “network”.
Options
The following table lists all available options for the apropos
command:
Option | Description |
---|---|
-d |
Specify a different database to search. By default, apropos searches the whatis database. |
-e |
Search for exact matches only. |
-w |
Search for matches that start with the search string. |
-r |
Use regular expressions in the search string. |
-s |
Search for matches in the name of the command or function, instead of the short description. |
-u |
Display the usage information for the command or function. |
-l |
Display the file location for the command or function. |
-m |
Display the man page for the command or function. |
Troubleshooting tips
If the apropos
command does not return any results, it is possible that the whatis database has not been updated. You can update the database by running the makewhatis
command as the root user:
sudo makewhatis
This command will update the whatis database with the latest information about Unix commands and functions.
Notes
The apropos
command is a useful tool for finding Unix commands and functions that you may not be familiar with. By searching through the short descriptions in the whatis database, you can quickly find commands and functions that are related to a specific topic or task.