Select Page

Linux Apropos Command – Find the Right Hammer for Bash

Apropos command in Linux helps you to find your hammer, i.e. the right command to use to perform your work.

You’re sitting before your PC, a bash terminal waiting for your command. You know what you want to do but can’t remember what commands should you use. A Google search can help you, but you want to find out the commands locally for some reason. What should you do?

This is a very common scenario for all of us, isn’t it?

The Linux apropos command got your back in this kind of situation. The word “apropos” means “very appropriate to a particular situation”. As the name goes, the apropos command gives you all the possible commands you may need depending on some keywords you give it.

Say you forgot what command to use to edit a text file. Here the keyword is “text editor”. If you provide the apropos command this simple keyword, it would list out all the possible commands you can use.

How does the Linux apropos command work

Each command has a short description in their manual about what it performs. When you pass some keywords to the apropos command, it searches all the available commands and those short descriptions to find a match. Finally, it lists out all the matches depending on the options you provide it.

The basic syntax of the apropos command:

$ apropos [option] keywords

Note that you can use more than one keyword. The apropos command has some default options. You’ll see this later.

Now, to find out what command can be used to edit a text file, run this:

$ apropos 'text editor'

Carefully notice that I wrapped the keyword with single quotes to make it a raw string. If you don’t do it, then ‘text’ and ‘editor’ will behave as 2 different keywords. You’ll find out later why it’s a good practice to wrap keywords that contains space.

apropos command example by finding a list of all the available text editors
apropos command example
  • To understand those numbers, read this StackExchange answer when you’re comfortable with apropos.

Here either the commands or the short descriptions matched the keyword.

You can use multiple keywords to find the available commands. By default, each keyword will be used as alternatives. So all the commands will be listed that match any of the provided keywords. That’s why the list will be longer. Try this:

$ apropos copy cut paste

This will list out all the commands that can perform any kind of copy or paste or cut operations.

Available options in Linux apropos command

To find out all the available options in the apropos command, look for the manual or the help file.

$ man apropos
$ apropos --help
$ apropos --h

And the output:

The user manual for the apropos command
apropos command user manual

-d or –debug

Prints debugging messages for the matched commands. It lists out their manual page directories, global paths, path directories, and a detailed information for each of the matched commands.

$ apropos -d delete

-v or –verbose

Prints verbose warning messages, if any. Verbose means extra information, using more words than necessary to describe a situation.

$ apropos -v delete

You might not see any changes if there’s no error.

-r or –regex: Default

Translates each keyword as a regex or regular expression. That means, when you search for sudo, you get a list where sudo can either be an independent word or part of a word. It is the default behavior of the apropos command.

$ apropos -r sudo
apropos regex
apropos regex

-e or –exact

As the default behavior is to consider the keywords as regex, you can choose to match exactly as the keywords are given. In that case, use this option. The matching list will be shorter than the previous option.

'exact' command to match a search exactly as given
apropos exact

Remember, the keyword can match either the possible commands or their short descriptions.

-w or –wildcard

If your keyword contains wildcards, then use this option.

$ apropos -w del*

-a or –and

When you use multiple keywords, then the Linux apropos command looks for commands that matches any of the keywords. But in case you want it to match all of the given keywords, then use the -a or and option.

$ apropos -a editor code
$ apropos -a text editor
matching all of the keywords with -a or --and command
matching all of the keywords

Seems like I don’t have a match for code editor 🙂

-l or –long

If the search results don’t fit your screen size, it will be truncated or shortened. You can see 3 dots at the end of some lines. Sometimes it becomes tough to know what that command stands for. In that case, you can ask the apropos to show a longer version i.e. the full description.

$ apropos git-tag
$ apropos -l git-tag

Here’s the output:

long option to view full description
long option

Reporting bugs for Linux apropos command

As described in the manual page, report apropos command related bugs here.

Conclusion

If you’re new to Linux or Bash, and not following all the tutorials serially, try reading these recommended tutorials:


Mind Sharing It?
Join Facebook Group

Public Group

A group optimized for learning purposes. Track your progress by joining a unit

Follow on Quora

Public Space

Best place to ask questions! Join the built-in community to get help from others