whatis, which, whence, where, whereis, type, apropos

command lines in this article assumes zsh.

whatis(1)

whatis - display one-line manual page descriptions. useful options:

  • -r --regex: interpret each keyword as a regex
  • -w --wildcard: keyword(s) contain wildcards
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
$ whatis gcc
gcc (1) - GNU project C and C++ compiler

$ where whatis
/usr/bin/whatis

$ whatis -r '^wh'
whatis (1) - display one-line manual page descriptions
whereis (1) - locate the binary, source, and manual page files for a...
which (1) - locate a command
whiptail (1) - display dialog boxes from shell scripts
WhitePixel (3) - Display macros and functions
WhitePixelOfScreen (3) - screen information functions and macros
who (1) - show who is logged on
whoami (1) - print effective userid
whois (1) - client for the whois directory service
whois.conf (5) - alternative WHOIS servers list for whois client

which(1)

In zsh, this is a shell built-in command:, equivalent to whence -c. In bash, this is /usr/bin/which.
Useful options (for /usr/bin/which):

  • -a: print all matching pathnames of each argument
1
2
3
4
5
6
7
$ whatis which
which (1) - locate a command

$ where which
which: shell built-in command
/usr/bin/which
/bin/which

whence

whence is a zsh built-in command. Useful options:

  • -w: For each name, print ‘name: word’ where word is one of alias, builtin, command, function, hashed, reserved or none
  • -f: Causes the contents of a shell function to be displayed
  • -p: Do a path search for name even if it is an alias, reserved word, shell function or builtin.
  • -a: Do a search for all occurrences of name throughout the command path.
  • -m: The arguments are taken as patterns (should be quoted)
  • -c: Print the results in a csh-like format. e.g. which in zsh.

where

where is a zsh built-in command, equivalent to whence -ca.

1
2
3
$ where grep
grep: aliased to grep --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn}
/bin/grep

whereis(1)

whereis - locate the binary, source, and manual page files for a command.

Note: the supplied names are first stripped of leading pathname components and any (single) trailing extension.

Useful options:

  • -b: Search only for binaries
  • -m: Search only for manual sections
  • -s: Search only for sources
1
2
3
4
5
6
7
8
9
10
$ whereis stdio
$ # or
$ whereis stdio.h
$ # or
$ whereis stdio.cpp
$ # or
$ whereis stdio.any_extension
$ # or
$ whereis /any/path/stdio.any_extension
stdio: /usr/include/stdio.h /usr/share/man/man3/stdio.3.gz

type

type is a shell built-in command, equivalent to whence -v.
Bash shell also has this command with equivalent functionality.

1
2
3
4
5
$ type zsh
zsh is /usr/bin/zsh

$ type which
which is a shell builtin

apropos(1)

apropos - search the manual page names and descriptions.
Each manual page has a short description available within it. apropos searches the descriptions for instances of keyword. Keywords are regex by default.

Useful options:

  • -r, --regex: Interpret each keyword as a regular expression. This is the default behaviour
  • -w, --wildcard: Interpret each keyword as a pattern containing shell style wildcards
  • -L locale, --locale=locale
1
2
$ apropos '^std'  
$ # search C++ standard library functions (need to install doc package first).