Linux whereis Command: Locate Binaries, Source, and Man Pages

The whereis command locates binaries, source files, and manual pages associated with a program name. Unlike which, which focuses on PATH executables, whereis can report several related file types in one query.

This guide explains the basic syntax, key options, practical examples, related commands, common cautions, and frequently asked questions for whereis.

What Is the whereis Command?

The util-linux implementation builds its lookup locations from known system paths and environment information. It does not recursively scan the entire filesystem, so custom installation trees and arbitrary user directories may be absent unless the search paths are overridden.

Basic Syntax

whereis [OPTION]... NAME...

Options and edge cases can vary by implementation and version. Check whereis --help and man whereis on the target system before relying on implementation-specific behavior.

Basic whereis Usage

Find all related locations

The output can include binary and manual paths on one line.

whereis bash

Search only for binaries

Use -b to restrict the selected file type.

whereis -b ssh

Search only for manuals

Use -m to locate manual-page files.

whereis -m printf

Distinguishing Between Binary and Manual Locations

whereis searches for standard locations of executable files, manuals, and related items by name. It does not recursively search the entire disk.

whereis ls

Example output (installation paths vary depending on the environment):

ls: /usr/bin/ls /usr/share/man/man1/ls.1.gz

The first path is the executable file, and the latter path is the manual file. If you want to know the executable path that the current shell actually selects, use type or command -v.

Key Options

Option Purpose
-b Search for binaries.
-m Search for manual pages.
-s Search for source files.
-B DIRS -f Set binary search directories.
-M DIRS -f Set manual search directories.
-S DIRS -f Set source search directories.
-u Report unusual entries for the selected search types.
-l List effective lookup paths.

Practical Examples

List effective search paths

Use this first when a result is missing or unexpected.

whereis -l

Use custom binary paths

The -f marker terminates the directory list and begins the program names.

whereis -B /usr/local/bin /opt/tools/bin -f mytool

Compare shell resolution and related files

Check what the shell executes separately from where related files are stored.

command -v python3
whereis python3

whereis and Related Commands

Command Primary role Best fit
whereis Search known related-file locations Binaries, source, and manuals
which Search PATH executables External command path
type Classify shell command forms Aliases, functions, and builtins
find Walk arbitrary paths Custom locations and complex tests

Important Cautions

It is not a full-disk search

Files outside the effective search paths can be omitted.

Pass program names rather than arbitrary paths

Leading path components and recognized suffixes are handled according to the implementation's name rules.

Remember -f after custom path lists

Without the separator, directory and program-name operands can be interpreted differently than intended.

FAQ

Does whereis search only PATH?

No. It uses standard binary, source, and manual locations as well as relevant environment paths.

Why is a custom installation missing?

Its directory may not be in the effective search set. List or override the lookup paths.

How do I see the search paths?

The util-linux version supports whereis -l.

How do I search the whole filesystem?

Use find for a live traversal or locate for an indexed name search.

Related Resources

More in This Category
Linux date Command: Display and Format the Current Time

Linux date Command: Display and Format the Current Time

Learn how to display and Format the Current Time with the Linux date command, including practical examples, key options, and important precautions.

Linux fdisk Command: Inspect and Edit Disk Partitions

Linux fdisk Command: Inspect and Edit Disk Partitions

Learn how to inspect and Edit Disk Partitions with the Linux fdisk command, including practical examples, key options, and important precautions.

Linux join Command: Combine Files by a Common Field

Linux join Command: Combine Files by a Common Field

Learn how to combine Files by a Common Field with the Linux join command, including practical examples, key options, and important precautions.

Linux realpath Command: Resolve Absolute and Canonical Paths

Linux realpath Command: Resolve Absolute and Canonical Paths

Learn how to use the Linux realpath command to resolve relative paths, symbolic links, and redundant path components, with essential options, practical examples, output interpretation, and common troubleshooting tips.

Linux whoami Command: Show the Effective User Name

Linux whoami Command: Show the Effective User Name

Learn how to show the Effective User Name with the Linux whoami command, including practical examples, key options, and important precautions.

Linux last Command: Review Login and Reboot History

Linux last Command: Review Login and Reboot History

Learn how to use the Linux last command to review user login sessions, system reboots, and shutdown history, with essential options, practical examples, output interpretation, and common troubleshooting tips.

Linux resolvectl Command: Inspect systemd DNS Resolution

Linux resolvectl Command: Inspect systemd DNS Resolution

Learn how to inspect systemd DNS Resolution with the Linux resolvectl command, including practical examples, key options, and important precautions.

Linux cd Command: Change the Current Directory

Linux cd Command: Change the Current Directory

Learn how to use the Linux cd command to move between directories using absolute, relative, home, and previous paths, with essential options, practical examples, output interpretation, and common troubleshooting tips.

Linux pkill Command: Signal Processes by Name

Linux pkill Command: Signal Processes by Name

Learn how to signal Processes by Name with the Linux pkill command, including practical examples, key options, and important precautions.

Linux parted Command: Inspect and Manage Partitions

Linux parted Command: Inspect and Manage Partitions

Learn how to inspect and Manage Partitions with the Linux parted command, including practical examples, key options, and important precautions.