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 nc Command: Test TCP and UDP Connections

Linux nc Command: Test TCP and UDP Connections

Learn how to test TCP and UDP Connections with the Linux nc command, including practical examples, key options, and important precautions.

Linux shred Command: Overwrite File Data and Understand Its Limits

Linux shred Command: Overwrite File Data and Understand Its Limits

Learn how Linux shred overwrites file data, which options control its passes and removal, and why SSDs, snapshots, backups, and modern filesystems limit its guarantees.

Linux command Command: Run Commands While Bypassing Aliases and Functions

Linux command Command: Run Commands While Bypassing Aliases and Functions

Learn how to use the Linux command command to check command availability and bypass shell aliases or functions, with essential options, practical examples, output interpretation, and common troubleshooting tips.

Linux getent Command: Query Users, Groups, and Other NSS Databases

Linux getent Command: Query Users, Groups, and Other NSS Databases

Learn how to query Users, Groups, and Other NSS Databases with the Linux getent command, including practical examples, key options, and important precautions.

Linux xargs Command: Pass Standard Input as Command Arguments

Linux xargs Command: Pass Standard Input as Command Arguments

Learn how to pass Standard Input as Command Arguments with the Linux xargs command, including practical examples, key options, and important precautions.

Linux basename Command: Extract the Final Component of a Path

Linux basename Command: Extract the Final Component of a Path

Learn how to use the Linux basename command to remove directory prefixes and optional suffixes from path strings, with essential options, practical examples, output interpretation, and common troubleshooting tips.

Linux rm Command: Remove Files and Directories Safely

Linux rm Command: Remove Files and Directories Safely

Learn how to remove files and directory trees with Linux rm, use interactive safeguards, limit recursive deletion, and avoid destructive path mistakes.

Linux Tutorial / How the Shell Runs Commands: ;, &&, ||, Aliases, and Environment Variables

Linux Tutorial / How the Shell Runs Commands: ;, &&, ||, Aliases, and Environment Variables

Learn how Bash resolves commands and uses exit status with ;, &&, and ||, then distinguish aliases, shell variables, and exported environment variables.

Linux scp Command: Copy Files over SSH

Linux scp Command: Copy Files over SSH

Learn how to copy Files over SSH with the Linux scp command, including practical examples, key options, and important precautions.

Linux screen Command: Create and Manage Detachable Terminal Sessions

Linux screen Command: Create and Manage Detachable Terminal Sessions

Learn how to use the Linux screen command to keep terminal sessions running and reconnect to them later, with essential options, practical examples, output interpretation, and common troubleshooting tips.