whereis Command Guide
whereis locates a program’s binary, its source code, and its manual
page, all in one shot. Where which answers “which executable
runs?”, whereis answers “where does this program live on disk — the
binary, the docs, and everything else?”
What is whereis, and Why Use It?
You’ve found a command with which, but you also want its man page, or
you’re packaging software and need to know where the sources are.
whereis queries the system’s file database for a name and reports
everywhere it appears, bucketed by type:
- binary — the executable
- man — the manual page
- source — source code (if available)
It’s faster than searching the filesystem by hand, and it understands the
standard layout of a Linux system, so it finds things find / would miss
or take minutes to reach.
# Where is git?
whereis git
# git: /usr/bin/git /usr/lib/git-core /usr/share/man/man1/git.1.gz
# Where is python?
whereis python3
# Where is the bash manual?
whereis -m bash
Basic Usage
# All categories at once
whereis ls
# Only the binary
whereis -b ls
# Only the man page
whereis -m ls
# Only source (if the package kept it around)
whereis -s ls
# Several programs at once
whereis tar gzip wget
Output format is name: path1 path2 .... An empty category simply
doesn’t appear — if you see ls: with nothing after it, the name is not
in the database.
Finding Man Pages and Docs
This is where whereis beats which for exploration:
# You know the command, want the docs
whereis -m ssh
# ssh: /usr/share/man/man1/ssh.1.gz
# Now read it
man ssh
It’s also useful when a man page seems to be missing — maybe it’s installed but under an unusual name:
whereis nginx
# nginx: /usr/sbin/nginx /etc/nginx /usr/share/man/man8/nginx.8.gz
Note that config directories and other non-binary locations can show up too, depending on the distribution’s database.
whereis vs which vs locate vs find
| Tool | Scope | Speed | Finds |
|---|---|---|---|
| which | PATH only | Instant | First executable match |
whereis | System name database | Fast | Binary, man, source |
locate | Whole-filesystem DB | Fast | Any file (DB may be stale) |
find | Live filesystem | Slow | Anything, always current |
# The full discovery workflow
whereis docker # quick: binary + docs
locate -i docker # broader: anything named docker
find / -name 'docker*' 2>/dev/null # exhaustive, but slow
Updating the Database
whereis (like locate) depends on a database that’s refreshed
periodically. If a program was installed recently and whereis can’t
find it:
# Debian/Ubuntu
sudo updatedb
# Fedora/RHEL
sudo updatedb # provided by the locate package
# Arch
sudo updatedb
After updatedb, whereis and locate see the new files.
Common Pitfalls
- Empty output doesn’t mean “not installed.” It means “not in the
whereis database.” The binary may exist but the database is stale — run
sudo updatedbfirst, or check with which. - No PATH awareness.
whereisdoesn’t know yourPATHor which copy would actually run. For that, usewhichortype. - Source rarely exists. Most distros strip source from installed
packages; an empty
source:field is normal, not a broken install. - Case sensitivity. Like most Linux tools,
whereis Git≠whereis git. - Not for config archaeology. It reports some extra paths but isn’t
a general file finder — use
locateorfindfor that.
Related Pages
- which — which executable would run
- type — what a command name really is
- man — read the manual page
whereis -mfound - info — the other documentation system
- PATH — the search order that
whichuses
Cheatsheet
| Command | What it does |
|---|---|
whereis git | Binary, man, and source locations for git |
whereis -b cmd | Binary only |
whereis -m cmd | Man page only |
whereis -s cmd | Source only |
whereis tar gzip | Several programs at once |
sudo updatedb | Refresh the database when results are stale |