Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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

ToolScopeSpeedFinds
whichPATH onlyInstantFirst executable match
whereisSystem name databaseFastBinary, man, source
locateWhole-filesystem DBFastAny file (DB may be stale)
findLive filesystemSlowAnything, 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 updatedb first, or check with which.
  • No PATH awareness. whereis doesn’t know your PATH or which copy would actually run. For that, use which or type.
  • 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 locate or find for that.
  • which — which executable would run
  • type — what a command name really is
  • man — read the manual page whereis -m found
  • info — the other documentation system
  • PATH — the search order that which uses

Cheatsheet

CommandWhat it does
whereis gitBinary, man, and source locations for git
whereis -b cmdBinary only
whereis -m cmdMan page only
whereis -s cmdSource only
whereis tar gzipSeveral programs at once
sudo updatedbRefresh the database when results are stale