whereis - macOS


Overview

whereis is a command-line tool used to locate the binary, source, or man page of a specified program or command. It is commonly used to find the path to an executable file or to determine if a particular program is installed on the system.

Syntax

whereis [options] [program]

Options/Flags

  • -b: Search only for binary files (executables)
  • -m: Search only for man pages
  • -s: Search only for source code files
  • -u: Search all three categories: binaries, man pages, and source code
  • -l: Display the long format, providing more detailed information
  • -r: Search for related information, such as documentation or examples
  • -R: Perform a recursive search for related information within subdirectories
  • -d: Search only the directories specified in the PATH environment variable

Examples

  • Find the location of the ls binary:
$ whereis ls
ls: /bin/ls /usr/bin/ls
  • Check if nano is installed by searching for its man page:
$ whereis -m nano
nano: /usr/local/man/man1/nano.1
  • Find all related information about git:
$ whereis -rR git
git: /usr/local/bin/git /usr/local/var/git /usr/local/share/man/man1/git.1

Common Issues

  • Command not found: Ensure that the program you are searching for is installed and in the PATH environment variable.
  • Multiple results: Use the -l option to display additional details about each result.
  • No matches: Verify the spelling of the program name or specify the full path.

Integration

  • With which: Use which to find the exact path to an executable binary, and then whereis to find additional information about it.
  • With find: Use find to search for related files or directories based on specific criteria, and then whereis to locate the associated program.
  • With man: Use man to display the man page for a program, and then whereis to locate the binary or source code file.
  • which
  • find
  • man