Linux Commands

apropos Linux Command

Linux OS comprises several different commands, and it is difficult to keep track of every command. At times users might need help remembering which command should be used. The apropos command in Linux can be utilized for situations like these. This command iterates over all the manual pages to search for the specific keyword passed to it in the command line.

This write-up will provide insight into the potential uses of apropos command in Linux.

apropos Linux Command

The apropos command is used to search man pages and helps the user to find any command required.

Syntax

The basic syntax for the apropos command in the Linux environment is:

apropos [option] keyword

 

The apropos command can work without options but requires a keyword. Because a keyword is necessary to search in the man pages.

However, if this command is run without the keyword:

apropos

 

It will literally ask for “apropos what?”.

Let’s have a sneak peek into the options available for the apropos command that assists in searching man pages in a more efficient and convenient way.

apropos Linux command options

There are numerous apropos command options, a few are as follows:

-e: for exact match search

-d: for showing debugging messages.

-s: searches in only specific manual pages.

-L: sets the locale for search.

-r: shows each keyword as regex.

-a: exhibits the property of AND. Returns output when all keywords match in the manual section page.

Practical Implementation

Let’s run a couple of widely used commands to have a diverse yet clear understanding of what apropos command is capable of.

The apropos command can help in numerous situations. Some examples are mentioned below.

Example 1: How to Search for a Specific Keyword Using apropos Command?

To find a specific keyword in all the manual pages section, run the following apropos command

Suppose, we want to search for a command that helps in file/password encryption. We will search simply for:

apropos encryption

 

It can be observed from the output that all the commands and descriptions that include the “encryption” keyword are listed.

Example 2: How to Search for an Exact Match Keyword Using apropos Command?

If the user wants to search for an exact match and does not want the word as part of some other word, run the following command:

apropos -e encrypt

 

In the output, only those commands are listed which include the exact match of “encrypt”.

Example 3: How to Avoid Word trimming in apropos Command?

The apropos command trims the output description by default(can be seen in Example 1). The output shows up on screen ending in an ellipsis(…).

To avoid trimming, use the command with the -l option.

apropos -l encryption

 

As it can be seen in the output, the description of “EVP_KEYMGMT-SM2 (7ssl)” and a couple of other commands are displayed without trimming.

Example 4: How to Display message debugging in apropos Command?

For message debugging use the following command:

apropos -d ptargrep

 

When this command is executed, the terminal returns manual directories, global paths, warnings, etc. of each command matching with the keyword.

That’s it from the apropos command and its options which assist in searching and finding commands efficiently.

Conclusion

In Linux, the apropos command serves as a useful search tool that enables users to locate commands based on keywords. It is a flexible tool for a variety of situations from precise keyword match, message debugging, etc due to its easy-to-use syntax and multiple options. apropos command can be used to navigate through Linux command lines and to perform functions such as checking for file compression, avoiding word trimming, and making use of debugging techniques.

About the author

Shehroz Azam

A Javascript Developer & Linux enthusiast with 4 years of industrial experience and proven know-how to combine creative and usability viewpoints resulting in world-class web applications. I have experience working with Vue, React & Node.js & currently working on article writing and video creation.