whereis Command in Linux: Find Its Files

whereis Command in Linux: Find Command Files

Finding files associated with a Linux command means knowing what kinds of files to look for. The whereis command searches its configured locations for files associated with a command.

This article explains how to read whereis results and narrow a lookup by file category or directory.

TL;DR

The whereis command searches for a command’s executable, source files and manual pages in its configured lookup locations.

  • Use whereis name to see the available categories.
  • Use -b, -m or -s to select binaries, manuals or sources.
  • Use -B, -M or -S with -f to specify search directories.

What Does the whereis Command Find?

The command reports the executable, source and manual files it can locate for a name.

Each result starts with the name passed to the command.

How to Use whereis in Linux Step by Step

Use an option only when the default lookup needs narrowing.

Step 1: Find the available files for a command

Run the general lookup first. This capture compares it with separate binary and manual lookups.

bash whereis_demo.sh

The script contains the exact three commands shown below, and the captured terminal image shows their output.

whereis: /usr/bin/whereis /usr/share/man/man1/whereis.1.gz
whereis: /usr/bin/whereis
whereis: /usr/share/man/man1/whereis.1.gz
whereis command output for binary and manual paths
The terminal shows the combined result followed by binary-only and manual-only results.

Step 2: Select binaries, manuals or source files

Choose a file category when the general lookup returns more paths than you need. The lowercase selectors show binary, manual or source matches separately.

whereis -b bash
whereis -m bash
whereis -s bash

Step 3: Limit a search to chosen directories

Uppercase directory options set the locations searched for each file type. The end marker separates those directory arguments from the names to look up.

whereis -b -B /usr/bin -f bash

Use existing absolute paths for a restricted lookup. The example checks the binary directory you provide, then treats the following name as the query.

The unusual-result selector can filter names by the count of matching files. Pair it with a type selector to limit which category is counted.

Why Does whereis Return No Path?

whereis jd-no-such-command-20261020
whereis output when no matching command files are found
The queried name appears without a path.

For a one-line manual description, use the whatis utility. Open the full page with the man command when you need its usage details. To inspect whatis syntax, see our guide to the whatis command in Linux.

The whereis(1) manual includes examples showing how directory restrictions affect later names on one command line.

whereis -m -u bash

The help and version switches both print information and exit. Help lists supported options, while the version switch reports the installed program version. These do not locate command files, so use them when checking the utility itself rather than searching for another program.

whereis --help
whereis --version

Use the help output for a quick reminder of available switches.

Path restrictions affect later names on the command line, and a new restriction resets the search mask. The upstream manual demonstrates this with a sequence that searches one name in default locations and a later name in a supplied directory.

When a name includes a directory prefix, whereis strips leading path components before searching. Its glob option matches file basenames, so a directory component in a wildcard expression does not constrain the lookup.

Common whereis Lookup Limits

Check the active path list before switching to a broader search, since built-in locations vary across systems and distributions.

whereis -l

A source category can be empty when source files were not installed. The glob selector can check several basenames, but shell quoting matters because the shell may expand an unquoted wildcard before whereis receives it.

Conclusion: Read the Paths as Categories

Use whereis when you need to locate command-related files, then choose a shell lookup or filesystem search when the task calls for one.

FAQ

These answers cover common choices when looking up a command.

What is the difference between which and whereis?

which or type reports executable resolution through the shell’s command lookup, while whereis searches for binaries, manuals and source files in its lookup paths.

How do I find only the binary with whereis?

Run whereis -b followed by the command name, such as whereis -b bash.

Why does whereis show no paths?

No matching files were found in the search paths for the requested types. Check the paths with whereis -l or use a search tool suited to the location you expect.