apropos command in Linux with examples

In Linux, there are hundreds of commands and they can become quite difficult to keep track of. So, sometimes you might not be able to remember one when you need it. The apropos command in Linux can be used for situations just like this.

apropos searches all manual pages for commands with keywords that are passed to it in the command line. These keywords can be parts of the command names or related to their functionality descriptions. When used without flags, the apropos command functions in the exact same way as the man -k command.

In this tutorial, we’ll show you with examples the best way to utilize apropos and its various command line options.

In this tutorial you will learn:

  • How to use the apropos command on Linux
apropos command in Linux with examples
apropos command in Linux with examples
Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Any Linux distro
Software apropos
Other Privileged access to your Linux system as root or via the sudo command.
Conventions # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ – requires given linux commands to be executed as a regular non-privileged user

Frequently Used Options




apropos is a simple command, both in syntax and in purpose. Check out the examples below and you’ll have it mastered quickly.

apropos command in Linux Basic Examples

  1. We’ll use the rm command as an example to show you how to use the general syntax of apropos. The description of the rm command, as stated in the manual page, is “remove files or directories”. We can type part of this description in the command line to be used as keywords for apropos to search. But if we’re going to pass multiple keywords to apropos, we’ll have to surround them in quotes.
    $ apropos "remove files"
    

    Using apropos with a few keywords to search for the rm command
    Using apropos with a few keywords to search for the rm command
  2. When passing multiple keywords without quotes to apropos, it searches the manual pages for commands whose desciptions contain matches for at least one of the keywords specified to apropos. We showed in the example above that we can use quotes to force apropos to process each word as one keyword variable, but we can also achieve a similar effect with the -a command line option.
    $ apropos -a remove files or directories
    

    Using the syntax above, we’ll get the exact same output as we did in the previous example, despite omitting the quotes.

  3. Keywords that are passed to apropos are matched against other words in the man pages. But, by default, apropos considers these words as a match if they contain the keywords, even if the words aren’t an exact match. For example, if we are looking for a match to the keyword “log”, we could get a command description containing the word “changelog”. But using the -e command line option, we can force apropos to display exact matches to our specified keywords in its output.
    $ apropos -e "log file"
    

    Using apropos with and without the -e option to show how we can get an exact match
    Using apropos with and without the -e option to show how we can get an exact match
  4. If there’s a description in apropos‘s output that is too long, it will trim the text by default with “…”. We can use the -l command line option to force apropos to display the full length of a command’s description, no matter how long it is.


    $ apropos -l log
    
    Using apropos with the -l option to forego description trimming
    Using apropos with the -l option to forego description trimming

    As you can see in the screenshot above, when using the -l command line option, some of the command descriptions take up more than one line in the output of apropos.

Closing Thoughts

In this tutorial, we learned all about apropos on Linux. apropos is essential to master for users and administrators that frequently run Linux commands on the command line terminal. Not many of us can remember every obscure option for all the commands we tend to run, so apropos can come in handy for a quick search.