apropos - Linux


Overview

The apropos command is used in Unix-like operating systems to search the man pages for entries that match a given search term. It analyzes the man page descriptions in the whatis database and is especially useful for finding commands when you know their functionality but not their exact names.

Syntax

The basic syntax of the apropos command is:

apropos [options] keyword
  • keyword: This is the search term or pattern that apropos looks for in the man page descriptions.

Options/Flags

apropos command supports several options that modify its behavior:

  • -V, --version: Display version information.
  • -v, --verbose: Show more information including the path to the man page.
  • -r, --regex: Interpret the pattern as a regular expression.
  • -e, --exact: Match the pages with exactly the same name as the search pattern.
  • -l, --long: Do not trim the output to the terminal width. Also, show a one-line description for each match.
  • -a, --and: Interprets all given patterns as logical AND. Each term must exist on the page.
  • -o, --or: Default behavior, where displayed results contain any of the provided search terms.

Examples

Here are some examples to illustrate common uses of apropos:

  1. Basic Search:

    apropos partition
    

    Displays all entries related to the term “partition”.

  2. Verbose Output:

    apropos -v partition
    

    Shows detailed entries including the path to the man pages.

  3. Using Regular Expressions:

    apropos -r '^ssh'
    

    Finds all entries that start with “ssh”.

  4. Exact Match:

    apropos -e umount
    

    Returns man pages that exactly match “umount”.

  5. Logical AND Operation:

    apropos -a network file
    

    Displays entries that contain both “network” and “file”.

Common Issues

  • Database Out-of-Date: Sometimes, the whatis database might be out-of-date, causing apropos to return incomplete or outdated results. Regularly update the database with mandb.
  • Regular Expressions: Misformatted regular expressions can lead to unexpected results. Ensure proper regex syntax.

Integration

apropos can be combined with other commands to enhance its utility:

  • Combining with grep:

    apropos -v network | grep secure
    

    You can further filter the results related to “network” that also include “secure”.

  • Scripting Usage:

    #!/bin/bash
    # Quick search for command related to 'backup'
    apropos backup | while read -r line; do
      echo "Found: $line"
    done
    
  • man: Display the manual of commands.
  • whatis: Display one-line manual page descriptions.

For more details, please refer to the official man command documentation provided on your system.