Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

whereis looks for a command’s binary, manual page, and—on implementations that support it—source files in configured locations. Its results depend on the operating system and local search paths; it is not a universal test for whether a command is installed. The Linux, FreeBSD, and OpenBSD versions differ in what they search and which options they accept.

What the whereis command does

On Linux, whereis locates binary, source, and manual files for the command names you provide. It searches standard locations as well as locations derived from $PATH and $MANPATH. It also strips leading path components from a supplied name, so it is intended for searching by command name rather than verifying an exact pathname. The util-linux manual describes its purpose as locating binary, source, and manual files.

What counts as a match differs by implementation. FreeBSD searches standard binary, manual, and source directories, while OpenBSD checks standard binary directories for files executable by the user. A result therefore reflects the system’s configured search locations and installed files, not every file on disk.

Linux whereis syntax and options

The Linux syntax is:

whereis [options] [-BMS directory... -f] name...

Use these options to select result types or change where they are searched:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Option Effect
-b Search for binaries only.
-m Search for manual pages only.
-s Search for source files only.
-B Set binary search directories.
-M Set manual-page search directories.
-S Set source search directories.
-f End a directory list so following arguments are treated as command names.

For example, search a custom manual directory, then identify the name to look up:

whereis -m -M /usr/local/share/man -f mytool

Directory restrictions apply cumulatively to subsequent names. In whereis -bm ls tr -m gcc, the command searches binaries and manuals for ls and tr, then manuals only for gcc.

Useful Linux examples

Show all available categories

whereis bash

This requests binary, manual, and source results for bash from the configured search locations.

Find only the binary and manual page

whereis -bm bash

Look for unusual entries in selected directories

whereis -u -ms -M /usr/man/man1 -S /usr/src -f /usr/bin/*

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Here, -u reports unusual entries while the manual and source searches are restricted to the directories supplied with -M and -S. The -f separates those directory arguments from the names expanded from /usr/bin/*.

How FreeBSD whereis differs

FreeBSD checks standard binary, manual-page, and source directories. Its default binary search path is based on sysctl’s user.cs_path, with /usr/libexec and the user’s $PATH added. Manual searches use $MANPATH; source searches include trees such as /usr/src and /usr/ports. The FreeBSD manual documents these defaults and the utility’s search behavior.

FreeBSD also provides options that are not portable to every system:

  • -a prints all matches rather than limiting output to the usual match.
  • -q suppresses the command name in the output.
  • -x avoids expensive locate-based source searches.

To show every match for ls without the leading utility name, use:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

whereis -aq ls

To print the source-directory result and change into it, FreeBSD documents this shell example:

cd `whereis -sq ls`

The source lookup can depend on the availability and freshness of the local locate database. If a source result is missing or unexpected, check that source trees are present and that the database is usable.

How OpenBSD whereis differs

OpenBSD’s whereis checks standard binary directories and reports matches that are executable by the user. It normally reports the first match; use -a to report all matches. For example:

whereis -a sh

Unlike the Linux description, the OpenBSD manual focuses on executable files in standard binary directories rather than binary, manual, and source categories. See the OpenBSD manual for the platform’s options and behavior.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

OpenBSD documents exit statuses as follows: 0 when all specified names resolve, 1 when some resolve, and 2 when none resolve. Do not assume these status meanings apply identically to Linux or FreeBSD; consult the local manual.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Linux, FreeBSD, and OpenBSD compared

Implementation Default search focus Manual and source searches All matches and custom search controls Exit status
Linux (util-linux) Standard locations and paths derived from $PATH and $MANPATH. Supports binary, manual, and source categories. -B, -M, and -S set search directories; the documented options here do not establish a universal all-matches flag. Not stated in the cited util-linux manual information.
FreeBSD Binary paths based on user.cs_path, plus /usr/libexec and $PATH; manuals via $MANPATH; source trees including /usr/src and /usr/ports. Supports binary, manual, and source searches; source searches may use locate. -a shows all matches; -q suppresses the name; -x avoids expensive locate-based source searches. Not stated in the cited FreeBSD manual information.
OpenBSD Standard binary directories, limited to files executable by the user. Manual and source searches are not established by the cited manual description. -a shows all matches; custom directory controls are not stated in the cited manual information. 0 if all names resolve, 1 if some resolve, 2 if none resolve.

What to do when whereis finds nothing

A missing result does not prove that a command is absent. whereis searches implementation-specific configured locations; a command may be outside them, absent from the current $PATH, or represented by a file that does not meet that implementation’s matching rules.

  • To ask the shell which command it would run, use command -v name.
  • To search arbitrary filesystem locations, use find with an appropriate starting directory and permissions.
  • On Linux, check $PATH and $MANPATH, and verify any custom directories passed with -B, -M, or -S.
  • On FreeBSD, check whether the source trees exist and whether locate-based source information is available and current.
  • On OpenBSD, remember that reported binary matches must be executable by your user.

Because flags and semantics vary, run man whereis on the target machine before relying on a platform-specific option or exit status.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.