When a command exists in more than one place, or its documentation seems missing, the whereis command in Linux gives you a quick inventory of the binary, source, and manual files it can find. It searches standard system paths instead of crawling the whole filesystem, which makes it useful for PATH troubleshooting, documentation checks, and scripts that need stable binary paths.
Understand the whereis Command
Common whereis Use Cases
Use whereis when you need to answer one of these practical questions:
- Where the binary lives: Confirm the installed executable path before comparing it with shell resolution tools.
- Whether documentation is installed: Check whether man or info pages exist for a command without searching the whole filesystem.
- Which standard paths contain matches: Spot duplicate command files or related source/documentation entries in known system locations.
whereis vs which vs type vs locate
Four commands locate programs or files on a Linux system, each with a different scope. Understanding when to use each prevents confusion when their results differ.
| Command | What It Finds | Search Scope | Best Used For |
|---|---|---|---|
whereis | Binary, source, and man pages | Predefined standard system paths | Auditing what is installed and where docs live |
which | First binary match in $PATH | Your current $PATH only | Checking which binary the shell runs |
type | Shell interpretation (alias, builtin, function, or file) | Shell environment | Diagnosing aliases and shell builtins |
locate | Files matching a name pattern (from a pre-built database) | Entire filesystem (indexed by updatedb) | Finding any file by name when the database is current |
If two versions of a tool are installed, whereis python3 may list both copies, while which python3 shows only the one your $PATH resolves first. Use whereis for a broad audit; see which command in Linux for checking exactly what the shell invokes.
Linux does not normally provide a separate Windows-style where command. If you searched for a where command in Linux, start with whereis for installed command files, command -v or type for shell resolution, and locate or find for broader file searches.
What whereis Does Not Search
whereis does not build or query an index database, does not scan every directory, and does not find files that exist only in repository metadata. It checks its effective search paths, including useful values from $PATH and $MANPATH, so use whereis -l when a result looks incomplete.
Package-manager file queries are a different job. On Alpine, apk search -v 'cmd:whereis' can identify the package that provides the command before installation, while apk info --who-owns /usr/bin/whereis checks an installed file owner. On Debian-family systems, use dpkg-query -S /usr/bin/whereis; on RPM systems, use rpm -qf /usr/bin/whereis. A query such as zypper info --files asks about package metadata, not whereis search behavior.
whereis Command Syntax
The fundamental structure of the whereis command is:
whereis [options] command_name
If you supply custom search paths with -B, -S, or -M, terminate the path list with -f before the command name to avoid errors.
For instance, to locate the binary, source, and documentation files for the ls command:
whereis ls
A typical full distribution returns the binary path and the installed manual page:
ls: /usr/bin/ls /usr/share/man/man1/ls.1.gz
Minimal images may show only the binary path if documentation packages are not installed.
On Alpine Linux and other distributions that keep separate
/binand/sbinpaths,whereis lscan returnls: /bin/lsinstead ofls: /usr/bin/ls. Modern distributions often merge these paths into/usr/bin, so both results are valid depending on the system.
whereis Command Quick Reference
These whereis flags control which file categories are searched and which paths are used.
| Flag | Description | Example |
|---|---|---|
-b | Binaries only | whereis -b ls |
-m | Manual and info pages only | whereis -m grep |
-s | Source files only | whereis -s ls |
-l | List all effective search paths | whereis -l |
-g | Interpret names as glob patterns | whereis -g 'lsc*' |
-u | Show entries missing or duplicating the requested file type | whereis -u -m ls grep |
-B <dirs> -f | Restrict binary search to specific directories | whereis -b -B /usr/bin -f ls |
-M <dirs> -f | Restrict manual search to specific directories | whereis -m -M /usr/share/info -f grep |
Check or Install the whereis Command
Most distributions include whereis as part of util-linux. Check the installed version before adding any package:
whereis --version
whereis from util-linux 2.39.3
If the shell cannot find the command, minimal containers or stripped images may have omitted the package. Install the package for your distribution.
Ubuntu and Debian-based distributions
Refresh the APT index, then install util-linux if your Debian-family system does not include it.
sudo apt update
sudo apt install util-linux
Running apt update refreshes the package index so you install the latest available release.
Fedora
On Fedora, install util-linux with DNF.
sudo dnf install util-linux
RHEL, Rocky Linux, AlmaLinux, and CentOS Stream
On RHEL and compatible distributions, install util-linux with DNF.
sudo dnf install util-linux
Arch Linux and Manjaro
Use Pacman to install util-linux on Arch-based systems.
sudo pacman -S util-linux
openSUSE
Use Zypper to install util-linux on openSUSE.
sudo zypper install util-linux
Alpine Linux
Alpine splits several util-linux tools into smaller packages. The whereis binary is provided by util-linux-misc; apk search -v 'cmd:whereis' should point to that package before installation. Run the install as root, or with sudo if your Alpine system has it configured.
apk add util-linux-misc
Gentoo
On Gentoo, install sys-apps/util-linux with Portage.
sudo emerge --ask sys-apps/util-linux
Void Linux
On Void, install util-linux with XBPS.
sudo xbps-install -S util-linux
The built-in help lists the option set available on the local util-linux release:
whereis --help
Usage: whereis [options] [-BMS <dir>... -f] <name> Locate the binary, source, and manual-page files for a command. Options: -b search only for binaries -B <dirs> define binaries lookup path -m search only for manuals and infos -M <dirs> define man and info lookup path -s search only for sources -S <dirs> define sources lookup path -f terminate <dirs> argument list -u search for unusual entries -g interpret name as glob (pathnames pattern) -l output effective lookup paths -h, --help display this help -V, --version display version For more details see whereis(1).
Practical Examples of whereis
Locate System Utilities
To locate the binary and associated files for the passwd utility:
whereis passwd
The output shows the binary, the local account database with the same basename, and available manual pages:
passwd: /usr/bin/passwd /etc/passwd /usr/share/man/man1/passwd.1ssl.gz /usr/share/man/man1/passwd.1.gz /usr/share/man/man5/passwd.5.gz
The /etc/passwd file is the local user database, not a command configuration file. whereis includes it because it matches the searched basename in a standard system path.
Locate Text Search Tools
To locate grep and confirm its documentation is installed (see grep command in Linux):
whereis grep
The output includes the binary, man page, and info documentation file when they are installed:
grep: /usr/bin/grep /usr/share/man/man1/grep.1.gz /usr/share/info/grep.info.gz
Info files are part of the documentation set that whereis reports alongside binaries.
Locate Stream Editors
To confirm the binary and documentation locations for sed (see sed command in Linux):
whereis sed
This returns the binary, man page, and info file paths:
sed: /usr/bin/sed /usr/share/man/man1/sed.1.gz /usr/share/info/sed.info.gz
Minimal systems may omit the man page or info file, so treat documentation paths as installed-state output rather than a universal default.
Locate Shells and Interpreters
Scripts often invoke shells like bash directly. To locate bash on the system:
whereis bash
The output shows the binary path and any installed manual page:
bash: /usr/bin/bash /usr/share/man/man1/bash.1.gz
Use this output to confirm whether a script’s shebang path exists. For portable Bash scripts, #!/usr/bin/env bash is often safer when the target environment controls $PATH.
Locate File Management Commands
To confirm the path for mkdir (see mkdir command in Linux):
whereis mkdir
This returns the binary path and related manual pages:
mkdir: /usr/bin/mkdir /usr/share/man/man1/mkdir.1.gz /usr/share/man/man2/mkdir.2.gz
Use this when troubleshooting PATH issues, then compare with command -v mkdir or which mkdir if you need the exact executable your shell runs.
Search Only Binaries
The -b flag restricts the search to binaries only, skipping man pages and source files:
whereis -b ls
The output shows only the binary location:
ls: /usr/bin/ls
In this output, the -b option directs whereis to display only the binary location. On modern distributions, /bin often points to /usr/bin, so you may see /usr/bin/ls even when searching for binaries only.
Search Only Source Files
The -s flag restricts results to source file locations:
whereis -s ls
On most systems, this returns an empty result because most distributions do not install source files by default:
ls:
If you install source packages for a command, -s will list those locations.
Search Manual and Info Pages
Manual pages and info pages are the built-in documentation for Linux commands. They provide detailed descriptions, options, and usage examples, and the -m option locates them.
whereis -m grep
grep: /usr/share/man/man1/grep.1.gz /usr/share/info/grep.info.gz
Minimal images may strip man pages or info files; on those systems, whereis -m shows only the documentation that is actually installed.
Locate Multiple Commands at Once
To look up multiple commands in a single call, pass all names as arguments:
whereis ls pwd
The output shows all found entries for each command on separate lines:
ls: /usr/bin/ls /usr/share/man/man1/ls.1.gz pwd: /usr/bin/pwd /usr/share/man/man1/pwd.1.gz
Combine Search Type Flags
Combine type flags to search only specific file categories. The -ms combination restricts results to manual pages and source files, skipping the binary entirely.
whereis -ms ls
On a system with manual pages but no source package installed, the result includes the man page and no source path:
ls: /usr/share/man/man1/ls.1.gz
Use -s alone when you only want source locations. Use -ms when documentation paths should appear but binary paths should not.
Advanced whereis Techniques
List whereis Search Paths
The -l option prints the directories whereis searches for binaries, sources, and documentation.
whereis -l
Relevant output includes path groups prefixed by search type:
bin: /usr/bin bin: /usr/sbin bin: /usr/lib/x86_64-linux-gnu bin: /etc bin: /usr/local/bin bin: /usr/share man: /usr/share/man/man1 man: /usr/share/man/man2 man: /usr/share/info
If an installed command is missing from the results, its files may live outside the listed paths. Use -B, -M, or -S with -f to extend the search to those directories.
Find Commands with Unusual Entries
The -u flag outputs entries that do not have exactly one match for each requested type. Combine it with -m to find commands with missing manual pages or duplicate documentation entries:
whereis -u -m ls grep sed gzip
Only commands with unusual manual-documentation counts appear in the output:
grep: /usr/share/man/man1/grep.1.gz /usr/share/info/grep.info.gz sed: /usr/share/man/man1/sed.1.gz /usr/share/info/sed.info.gz gzip: /usr/share/man/man1/gzip.1.gz /usr/share/info/gzip.info.gz
ls is omitted because it has exactly one manual entry in this search. grep, sed, and gzip appear because each has both a man page and an info file, giving more than one documentation result for the requested -m type.
Use Glob Patterns with -g
The -g option in newer util-linux releases interprets the name argument as a glob pattern. Quote the pattern so the shell does not expand it before whereis receives it:
whereis -g 'lsc*'
This example looks for installed files whose basename starts with lsc:
lsc*: /usr/bin/lscpu /usr/share/man/man1/lscpu.1.gz
Ubuntu 22.04 ships util-linux 2.37.2, which lacks the
-goption. On that release,whereis -g 'lsc*'returnswhereis: bad usage. List command names explicitly instead, for examplewhereis lscpu.
Limit the Search Path
whereis searches in standard directories by default, but you can limit the search to specific paths. The -B, -S, and -M options define custom paths, and -f ends the list before the command name.
whereis -b -B /bin -f ls
This command confines the search to /bin and shows only binaries:
ls: /usr/bin/ls
On modern distributions, /bin often points to /usr/bin, so the binary still resolves there.
Search a Specific Documentation Path
You can point the documentation search to a specific directory with -M. For example, search the info directory for grep documentation:
whereis -m -M /usr/share/info -f grep
grep: /usr/share/info/grep.info.gz
Use -M to direct documentation lookups to a specific directory when custom info paths are installed outside the defaults.
Search Multiple Binary Paths
whereis does not exclude directories directly, so define the paths you want to search. You can provide multiple directories after -B and end the list with -f:
whereis -b -B /usr/bin /usr/local/bin -f grep
grep: /usr/bin/grep
Add additional directories after -B as needed to cover custom binary locations.
Troubleshoot Common whereis Errors
Missing -f Option Error
If you see an error about a missing -f option, you did not separate the command name from the path list:
whereis -b -B /bin ls
whereis: option -f is missing
Add -f before the command name and rerun the lookup to confirm the result:
whereis -b -B /bin -f ls
ls: /usr/bin/ls
Empty Result After Lookup
If a lookup returns only a name and a colon, whereis did not find that requested file type in its search paths. On a minimal image without installed manual pages, a documentation-only lookup can look like this:
whereis -m ls
ls:
On a full distribution, the same command may return a man page instead. If the output is empty, confirm the executable exists in your $PATH before troubleshooting further:
command -v ls
/usr/bin/ls
Conclusion
With whereis, you can audit installed command files without waiting on a full filesystem search. Use -b, -m, and -s to narrow what it reports, then switch to find -exec in Linux for full-tree work or which in Linux when you need the exact executable your shell will run.


Formatting tips for your comment
You can use basic HTML to format your comment. Useful tags currently allowed in published comments:
<code>command</code>command<strong>bold</strong><em>italic</em><a href="https://example.com">link</a><blockquote>quote</blockquote>