The Linux command apropos is a tool that helps you search for commands using related keywords when you can’t recall the exact command but remember its function. The word apropos means “related to” in English, and it works by searching through the manual pages (man pages) for entries related to the keyword you provide.
Table of Contents
Basic Usage of the Linux Command apropos
The basic usage of the apropos
command is simple. You just need to enter the keyword you want to search for after apropos
.
apropos [keyword]
ShellScriptFor example, if you want to search for commands related to networks, you can enter the following:
apropos network
ShellScriptThis command will display a list of commands and their descriptions that are related to the word “network.”
As shown in Figure 1, a large number of commands can be displayed, making it hard to find the desired result. Let’s look at some ways to narrow down the search.
Main Options of the apropos Command
The apropos
command has several options that help refine the search results. These options allow for more precise control over what is displayed.
-e Option: Search for Exact Matches
The -e
option prints only the entries that exactly match the keyword you input. For example, if you search for “network,” only commands that exactly match “network” will be shown. Commands like “networking” will be excluded from the results.
apropos -e network
ShellScriptThis option is useful when you want to filter out too many results, but keep in mind that not all relevant results will be shown, so use it when necessary.
-a Option: Search Using Multiple Keywords
By default, apropos
searches for a single keyword, but with the -a
option, you can combine multiple keywords in your search. For example, if you want to search for commands related to both “file” and “copy,” you can enter the following:
apropos -a file copy
ShellScriptThis command finds entries related to both keywords.
-r Option: Use Regular Expressions
The -r
option allows you to use regular expressions (regex) to make your search more flexible. Regular expressions are a tool for pattern matching, which enables more complex searches based on specific rules. For instance, if you want to search for descriptions or commands that start with “net,” you can use the following:
apropos -r '^net'
ShellScriptThis command will display commands and descriptions that start with “net.”
Things to Keep in Mind When Using apropos
There are several points to note when using the apropos
command:
- Choosing the Right Keyword: Since
apropos
works based on keywords, entering the wrong keyword can lead to meaningless results. For example, “net” and “network” will yield different search results. It’s important to choose the keyword that best matches what you’re looking for. This is particularly important when using the-e
option, as it can lead to entirely different searches. - Installed Manual Pages Only: The
apropos
command searches only through the manual pages installed on your local system. If a manual page for a certain command is not installed, even if the command exists, it won’t be included in the search results. In such cases, you may need to install the manual page or refer to an online manual. - Using the Right Options: While
apropos
offers a variety of options, it’s important to choose the right one for the specific situation. For instance, when using the-r
option, ensure that the regular expression syntax is correct, as incorrect input can result in errors.
Summary
The Linux command apropos is a very useful tool for searching commands related to specific keywords. It’s especially helpful when you need to find new commands or quickly check a list of commands related to a certain function. With its various options, the apropos command allows for more detailed and flexible searches, including the use of regular expressions and multiple keywords.
Whether you’re trying to explore less frequently used commands, discover new features, or troubleshoot system issues, apropos can play a key role. Every Linux user should familiarize themselves with this command and use it in the appropriate context.