`apropos` is an overlooked Linux command

Search for Linux command that does what you need #

Sometimes the challenge of using the Linux command line is knowing what commands you need to do certain things. The apropos command lets you search the available commands by matching key words.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
❯ apropos csv
# bench_wcsv (3tcl)    - bench::out::csv - Formatting benchmark results as CSV
# csv (3tcl)           - Procedures to handle CSV data.
# csv2rec (1)          - csv to rec converter
# rec2csv (1)          - rec to csv converter


❯ apropos environment 
# 0desktop (1)         - add programs to the desktop environment
# 30-systemd-environment-d-generator (8) - Load variables specified by environment.d
# byobu-janitor (1)    - script for cleaning and upgrading environment after upgrades
# byobu-reconnect-sockets (1) - Sourcable script that updates GPG_AGENT_INFO and DBUS_SESSION_BUS_ADDRESS in the environment
# check-language-support (1) - returns the list of missing packages in order to provide a complete language environment
# clearenv (3)         - clear the environment
# dbus-update-activation-environment (1) - update environment used for D-Bus session services
# Dpkg::Build::Env (3perl) - track build environment
# env (1)              - run a program in a modified environment
# environ (7)          - user environment
# pam_env.conf (5)     - the environment variables config files
# ...

The command checks all of the installed man pages and package descriptions, however there are circumstances where this could leave out some relevant commands.

Search by matching multiple key words with “-a” #

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
❯ apropos -a environment variable
# environment.d (5)    - Definition of user service environment
# envsubst (1)         - substitutes environment variables in shell format strings
# envz (3)             - environment string support
# envz_add (3)         - environment string support
# envz_entry (3)       - environment string support
# envz_get (3)         - environment string support
# envz_merge (3)       - environment string support
# envz_remove (3)      - environment string support
# envz_strip (3)       - environment string support
# fakeroot (1)         - run a command in an environment faking root privileges for file manipulation
# fakeroot-sysv (1)    - run a command in an environment faking root privileges for file manipulation
# fakeroot-tcp (1)     - run a command in an environment faking root privileges for file manipulation
# getenv (3)           - get an environment variable
# gie (1)              - The Geospatial Integrity Investigation Environment
# gnome-session (1)    - Start the GNOME desktop environment
# go-env (1)           - print Go environment information
# ...

Exact match a keyword or phrase with “-e” #

1
2
3
4
5
6
❯ apropos -e "environment variable"
# getenv (3)           - get an environment variable
# putenv (3)           - change or add an environment variable
# secure_getenv (3)    - get an environment variable
# setenv (3)           - change or add an environment variable
# unsetenv (3)         - change or add an environment variable

All the available options #

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
❯ apropos -h
# Usage: apropos [OPTION...] KEYWORD...
# 
#   -d, --debug                emit debugging messages
#   -v, --verbose              print verbose warning messages
#   -e, --exact                search each keyword for exact match
#   -r, --regex                interpret each keyword as a regex
#   -w, --wildcard             the keyword(s) contain wildcards
#   -a, --and                  require all keywords to match
#   -l, --long                 do not trim output to terminal width
#   -C, --config-file=FILE     use this user configuration file
#   -L, --locale=LOCALE        define the locale for this search
#   -m, --systems=SYSTEM       use manual pages from other systems
#   -M, --manpath=PATH         set search path for manual pages to PATH
#   -s, --sections=LIST, --section=LIST
#                              search only these sections (colon-separated)
#   -?, --help                 give this help list
#       --usage                give a short usage message
#   -V, --version              print program version
# 
# Mandatory or optional arguments to long options are also mandatory or optional
# for any corresponding short options.
# 
# The --regex option is enabled by default.
#