Linux apropos Command: Search Commands by Description

apropos is a command that searches for keywords in the name and one-line description of manual pages when you do not know the exact command name. For example, it is useful for finding candidates when you know the task you want to do, such as "file compression," "user creation," or "network address," but do not know the related command.

man -k provides the same search functionality. Since the default search terms can be processed as regular expressions, understanding the relationships among multiple words, exact match searches, wildcards, and shell quoting rules can yield more accurate results.

What is the apropos command?

Each manual page has a short description summarizing its name and functionality. apropos searches the page names and descriptions in the man-db index database and outputs matching entries.

It is not a command to search the entire manual content. Therefore, the results are fast and good for finding topic-specific candidates, but pages that do not contain the keyword in the description may not appear even if the body has related content.

Basic syntax and reading results

apropos [option] keyword...

Here is an example of finding manuals related to file copying.

apropos copy

Typical results have the following structure.

cp (1)               - copy files and directories
scp (1)              - OpenSSH secure file copy

The first field is the manual page name, the number in parentheses is the section, and the description after the hyphen is a one-line explanation. Once you find the desired item, specify the section to open the exact page.

man 1 cp
man 1 scp

Multiple keyword search methods

The default is to display if at least one matches

When specifying multiple keywords, by default, items matching any one of them may be displayed. The search range may become wide, resulting in too many results.

apropos network address

Use -a if all keywords are required

-a or --and shows only items that match all specified keywords. It is useful for reducing unrelated results.

apropos -a network address
apropos --and user password

You can use quotes to group multiple words into a single search expression, but keep in mind that the default search is a regular expression.

Regular expressions, exact searches, and wildcards

Basic Regular Expression Search

the apropos of man-db treats keywords as regular expressions by default. Characters like dots, brackets, and asterisks can have special meanings, so to search for them literally, you need to escape them or use another search mode.

apropos '^ssh'
apropos 'file.*system'

The first example finds parts that start with ssh in the name or description, and the second example finds entries where there is any character after file and later system appears.

Exact Match -e

-e or --exact matches the keyword exactly with the page name or description. If you already know the exact page name, whatis might be simpler.

apropos -e printf

Shell-Style Wildcard -w

-w or --wildcard treats the keyword as a shell-style wildcard pattern. Quote the pattern so that the current shell does not first expand the asterisk to file names.

apropos -w 'ssh*'
apropos --wildcard '*password*'

Limit Search Scope to Sections

Using -s or --sections to limit the manual sections can reduce results with the same name from other documents or unrelated entries.

apropos -s 1 archive
apropos -s 2,3 socket
apropos --sections=5 password
Section Main content
1 Commands and programs run by general users
2 System calls provided by the Linux kernel
3 Program library functions
5 Configuration files and file formats
8 System management commands mainly used by administrators

The section list can be separated by commas or colons. Depending on the implementation and installed documentation, there may be subsections such as 3p or 3perl.

Commonly used apropos options

Option Description
-a, --and Only prints items that match all keywords.
-e, --exact Matches keywords exactly to page names or descriptions.
-r, --regex Treats keywords as regular expressions. This is the default search method in man-db.
-w, --wildcard Searches with shell-style wildcard patterns.
-s list, --sections=list Searches only the specified manual sections.
-l, --long Disables truncation of descriptions to fit terminal width.
-M path, --manpath=path Specify the manual hierarchy path to search directly.
-L locale, --locale=locale Temporarily specify the locale to use for the search.

What is the relationship between apropos and man -k?

In the man-db environment, man -k is an interface that uses apropos search options. The following two commands can be used for the same purpose.

apropos filesystem
man -k filesystem

You can choose according to your usage habits. If you want to emphasize that it is a process of finding a manual, man -k is suitable; if you want to remember it as an independent search command, apropos is more intuitive.

Points to check when no search results appear

Change to a more general keyword

Use English words that are likely to actually be included in the description. If the translated manual is not installed, results may not appear for a localized search term.

apropos compress
apropos archive
apropos -a user account

Updating the Index Database

Immediately after installing a new manual or if the index is corrupted, the results of apropos may be empty. In a man-db environment, you can update the index with administrative privileges.

sudo mandb

mandb creates or updates the manual page index cache. Since the system may automatically update it during package installation or periodic tasks, there is no need to run it repeatedly without reason.

Checking the Manual Paths and Locales

manpath
printf '%s\n' "$MANPATH"
locale

If you have set MANPATH manually or installed documents in a special path, the default manual hierarchy may be skipped in the search. The -M option can be used to temporarily specify a different path when diagnosing problems.

When Using in Shell Scripts

In man-db, apropos returns 0 if it runs normally, 1 for usage or configuration errors, 2 for operational errors, and 16 if there are no matching results. By distinguishing the exit status rather than just checking if the output is empty, you can differentiate between errors and no search results.

if apropos -e "$1" >/dev/null; then
 printf '%s\n' 'There are matching manual entries.'
else
 status=$?
 printf 'Search failed or no results: status=%d\n' "$status" >&2
fi

Exit status values may vary in other implementations. Before using it for automation, check man apropos on your current system.

Comparison of Commands Similar to apropos

Command Purpose
apropos keyword Searches for topics or keywords in the page name and one-line description.
whatis name Checks the one-line description of the exact manual page name.
man name Reads the full content of the selected manual page.
man -K string Search the entire installed manual text for a string. This may take a long time.

Frequently Asked Questions

Can I search with localized keywords?

Yes, if localized manual descriptions are installed and selected by the current locale. Many systems include only English descriptions, so try English keywords when a localized search returns no results.

What if the search term has spaces?

To pass it as a single expression, enclose it in quotes. If you pass multiple independent keywords and use -a, it will only find entries where each word matches.

Should I use apropos instead of which?

They have different purposes. apropos finds relevant manuals, and command -v or type checks how the entered command name is actually interpreted.

Summary

apropos is useful when you want to find a command or document by functionality keywords without knowing its name. You can find candidates with the basic search, satisfy multiple conditions with -a, and narrow down sections with -s to organize the results efficiently.

After finding the page you want, open it with man along with the section number. Other basic commands can be found in the List and Overview of Linux Commands.

Refer to official documents

More in This Category
Linux Tutorial / Standard Input, Output, Redirection, and Pipes

Linux Tutorial / Standard Input, Output, Redirection, and Pipes

Understand standard input, output, and error; practice file redirection and pipes; and learn why overwrite risk and redirection order matter.

Linux cp Command: Copy Files and Directories

Linux cp Command: Copy Files and Directories

Learn how to copy files and directories with Linux cp, control overwrites, preserve attributes, handle symlinks, and verify important copies.

Linux blkid Command: Find Block-Device UUIDs and Filesystem Types

Linux blkid Command: Find Block-Device UUIDs and Filesystem Types

Learn how to find Block-Device UUIDs and Filesystem Types with the Linux blkid command, including practical examples, key options, and important precautions.

Linux cut Command: Extract Characters and Fields

Linux cut Command: Extract Characters and Fields

Learn how to extract Characters and Fields with the Linux cut command, including practical examples, key options, and important precautions.

Linux wc Command: Count Lines, Words, Characters, and Bytes

Linux wc Command: Count Lines, Words, Characters, and Bytes

Learn how to use the Linux wc command to count lines, words, characters, and bytes in files or standard input, with essential options, practical examples, output interpretation, and common troubleshooting tips.

Linux bzip2 Command: Compress a File in bzip2 Format

Linux bzip2 Command: Compress a File in bzip2 Format

Learn how to compress a File in bzip2 Format with the Linux bzip2 command, including practical examples, key options, and important precautions.

Linux printenv Command: Print Environment Variable Values

Linux printenv Command: Print Environment Variable Values

Learn how to use the Linux printenv command to print all environment variables or selected variable values, with essential options, practical examples, output interpretation, and common troubleshooting tips.

Linux dig Command: Query DNS Records in Detail

Linux dig Command: Query DNS Records in Detail

Learn how to query DNS Records in Detail with the Linux dig command, including practical examples, key options, and important precautions.

Linux umask Command: Control Default File Permissions

Linux umask Command: Control Default File Permissions

Learn how to control Default File Permissions with the Linux umask command, including practical examples, key options, and important precautions.

Linux Disk Management: Partitioning, Formatting, and Mounting

Linux Disk Management: Partitioning, Formatting, and Mounting

Learn a safe Linux disk-management workflow for identifying devices, creating partitions and filesystems, mounting storage, and configuring persistent mounts.