apropos Linux Command Explained {with Examples}

October 11, 2022

Introduction

The apropos command helps users find any command using its man pages. Man pages describe command functions, list applicable arguments, and provide use-case examples. 

The man command invokes Linux command manual with the man command_name syntax. Therefore, not knowing the command name creates a problem. Unlike man, apropos searches all man pages using known details as a search term.

This guide offers apropos Linux command explained (with examples).

apropos Linux Command Explained {with Examples}

Prerequisites

  • A system running Linux.
  • Access to the terminal.

Note: The apropos command is case insensitive.

Linux apropos Command Syntax

The basic apropos syntax is:

apropos [option] keyword

The apropos command works without options but does not work without a search term (keyword).

Since apropos searches for a keyword in names and descriptions of man pages, running the command without a keyword prints the following:

apropos terminal output

Linux apropos Command Options

The apropos command works without any arguments. Still, options customize the output or affect the search process.

Some standard options are:

OptionDescription
-eReturns names and descriptions that match the keyword exactly.
-dPrints debugging messages.
-wSearches for the keyword with wildcards.
-aFunctions as logical AND. Returns output when all the keywords match.
-lStops output trimming.
-CUses user-configuration files instead of the $MANPATH.
-sSearches only in specific man pages sections.
-MSets the search path to PATH rather than the default $MANPATH.
-mLooks for man page descriptions from other OSs.
-LSets the locale for the search.
-rInterprets each keyword as a regex.

apropos Linux Command Examples

Searching a command by a keyword is handy when you cannot remember an exact command or when you try to find a suitable command to complete an action.

apropos helps in these situations and has plenty of use cases. Some examples are listed below.

Find a Keyword

The apropos primary usage is to find a single keyword in man pages. For instance, run apropos list to find instances mentioning the keyword list:

apropos list
apropos list terminal output

The command prints all instances of list in names (marked in green) and descriptions (marked in yellow). The tool also shows matches belonging to larger strings, like listener or lists.

Search Two Keywords

When the keyword is too broad, apropos outputs a lot of results. For list, apropos prints 300 lines. 

Add another variable to narrow down the matches. For instance, to list all the directories, use two keywords with apropos: list and directories.

Without arguments, apropos searches man pages that include list or directory. To ensure the output includes both, use -a:

apropos -a list directory
apropos -a terminal output

Achieve a similar effect without -a. by encasing keywords in double quotes:

apropos "list directory"
apropos 'list directory" terminal output

Double quotes instruct apropos to find the exact match, with the same order as keywords in quotes. Hence, the output provides four lines as opposed to six when using -a.

Find Either of Two Parameters

While the -a argument functions as logical AND, running apropos with several search terms without arguments functions as logical OR.

For instance, use delete, terminate, and remove as search terms to find man pages including either of the keywords:

apropos delete terminate remove
apropos three keywords terminal output

The apropos command prints lines containing one or more keywords.

 Find Exact Match

The apropos matches individual keywords or as part of another word. For example:

apropos set
apropos set terminal output

The output shows instances of set included in strings like offset and settings. To find exact matches for set, use the -e flag:

apropos -e set
apropos -e terminal output

Search Specific Sections

A man page for each command consists of nine sections. For example:

man man
man sections

By default, apropos searches for the keyword in any section. To specify the manual section to search for, use -s followed by the section number(s).

For instance, search for list in sections 1 and 8 with the following command:

apropos -s 1,8 list
apropos -s terminal output

The command printed man pages containing list in sections 1 or 8.

Use Regex Symbols

Use regex symbols to speed up the search process and filter the results.

For instance, find all man pages starting with the word list with:

apropos '^list'
apropos caret list terminal output

The keyword list is enclosed in single quotes with the caret symbol, ensuring that the term appears at the beginning of the line. The output shows that list appears at the beginning of the name column or the description column.

Regex expressions offer even more options. For example, find every man page that includes zipcloak, zipnote, or zipinfo with:

apropos "zip(note|cloak|info)"
apropos regex piping terminal output

The pipe functions as logical OR. The apropos command searches for zip with the cloak, note, or info suffix.

Use regex to conduct an even more specific search. For instance, find implementation, devices, or users in sections 3 or 8 on any man page that starts with list:

apropos -a -s 3,8 "^list" "(implementation|devices|users)"
apropos long regex command terminal output

As the output shows, each line includes list at the beginning, belongs to section 3 or 8, and has one of the keywords.

Avoid Trimming

The apropos command trims the description in output by default. The output is shown ending in an ellipsis. When running apropos with list, the trimming is evident in some places:

apropos trimming terminal output

Trimming is present despite the window size. To avoid the trimming, use the -l option:

apropos -l no trimming terminal output

Conclusion

After following this tutorial, you know how to use the apropos command to search through different man pages.

Next, check out the ultimate list of Linux commands all users should know.

Was this article helpful?
YesNo
Sara Zivanov
Sara Zivanov is a technical writer at phoenixNAP who is passionate about making high-tech concepts accessible to everyone. Her experience as a content writer and her background in Engineering and Project Management allows her to streamline complex processes and make them user-friendly through her content.
Next you should read
14 Dangerous Linux Terminal Commands
November 17, 2021

It is always dangerous to execute a Linux terminal command when you aren't sure what the command can do. This article lists 14 Linux commands that can have adverse effects on your data or system...
Read more
19 Crucial Linux ls Commands to Know
July 30, 2020

The ls command (short for “list”) lists information about directories and any type of files in the working directory. Learn how to use ls command in this article...
Read more
Vim Commands Cheat Sheet
July 22, 2020

Vim is an open-source text editor found in most Linux distributions. This article lists all the commonly used Vim commands and includes a downloadable one-page cheat sheet for future reference...
Read more
Linux Commands Cheat Sheet: With Examples
November 2, 2023

A list of all the important Linux commands in one place. Find the command you need, whenever you need it or download our Linux Commands Cheat Sheet...
Read more