Skip to main content
Commands

Search for Available Linux Commands With apropos

Can't remember a certain Linux command? Use the apropos command and search for it in the available commands.

Abhishek Prakash

Warp Terminal

So you used a certain command but cannot remember its exact name anymore?

You can use the ctrl+r keyboard shortcut in the terminal and reverse search through the shell history.

This could work if you had used the command on the same system. But what if you used it on some other Linux system or just came across it in some forum or website?

The good thing here is that there is a dedicated Linux command that lets you search with a string in the available commands on your system.

Search for Linux commands with apropos

The apropos command lets you search for a keyword in the man page name and description.

This should be sufficient in many cases to help you find the command you are looking for.

Using the apropos command is simple:

apropos [options] keyword

Here's an example. Let's say that you are looking for a command that has something to do with the CPU. You use the apropos command with CPU keyword:

apropos cpu

And it gives you all the commands that have CPU in its name or in the short description of its man page.

root@learnubuntu:~# apropos cpu
chcpu (8)            - configure CPUs
cpuid (4)            - x86 CPUID access device
cpuset (7)           - confine processes to processor and memory node subsets
lscpu (1)            - display information about the CPU architecture
msr (4)              - x86 CPU MSR access device
sched (7)            - overview of CPU scheduling
taskset (1)          - set or retrieve a process's CPU affinity

By default, the search is case insensitive and the keyword could be a regular expression. This is why you see lots of matches like CPUs, CPUID, etc.

If you want an exact match, you can use the option -e:

root@learnubuntu:~# apropos -e cpu
lscpu (1)            - display information about the CPU architecture
msr (4)              - x86 CPU MSR access device
sched (7)            - overview of CPU scheduling
taskset (1)          - set or retrieve a process's CPU affinity

Multiple keywords

If you provide more than one keyword, apropos returns all the entries that match at least one of the given keywords.

As you can see in the below example, there are 307 entries matching either network or pro.

root@learnubuntu:~# apropos network pro | wc -l
307

If your searched term contains more than one word, you can use quotes around them to search for the entire keywords with spaces.

root@learnubuntu:~# apropos "network pro"
mtr-packet (8)       - send and receive network probes

The above example requires you to have all the keywords together. You can use the -a option and have entries matching all the keywords in any order.

root@learnubuntu:~# apropos -a network pro
ip-netns (8)         - process network namespace management
mtr-packet (8)       - send and receive network probes

Search only for the user or system commands

You'll often find that the apropos command returns a huge output and not all of them are commands.

It's because it searches in all the sections of the entire man pages.

If you are familiar with man pages, you would know that section 1 has user commands and section 8 has system commands. Here's a quick recall:

Section Description
1 User Commands
2 System Calls
3 C Library Functions
4 Devices and Special Files
5 File Formats and Conventions
6 Games etc
7 Miscellanea
8 System Administration tools and Daemons

So, when you searched for CPU it showed results from all the sections. Notice the number after each 'command'.

root@learnubuntu:~# apropos cpu
chcpu (8)            - configure CPUs
cpuid (4)            - x86 CPUID access device
cpuset (7)           - confine processes to processor and memory node subsets
lscpu (1)            - display information about the CPU architecture
msr (4)              - x86 CPU MSR access device
sched (7)            - overview of CPU scheduling
taskset (1)          - set or retrieve a process's CPU affinity

You can refine the search and list entries only from the specific sections:

root@learnubuntu:~# apropos -s 1,8 cpu
chcpu (8)            - configure CPUs
lscpu (1)            - display information about the CPU architecture
taskset (1)          - set or retrieve a process's CPU affinity
💡
The man -k command will display the same result as the apropos command.

There are ways to get help in the Linux command line. The apropos command is one of them and surprisingly not many people are aware of it.

I hope you learned something new from this article. Stay tuned for more.

Abhishek Prakash