Cybersecurity Updates & Tools

whereis Command in Linux: Find Binary, Source, and Man Pages

The whereis command locates the binary, source, and manual page files for a given command. Unlike which, it searches beyond $PATH, it checks hard-coded system paths and directories from environment variables.

How to Use the whereis Command in Linux

The syntax is:

bashwhereis [OPTIONS] FILE_NAME...

Run without options to search for all three types at once:

bashwhereis bash

Output: bash: /bin/bash /etc/bash.bashrc /usr/share/man/man1/bash.1.gz

Each result shows the command name, binary path, source search matches, and man page path. Most commands do not have C source files installed. When whereis returns a file from the source search paths — like /etc/bash.bashrc — it found that file in the source directories, not the actual C source code.

If the command is not installed, whereis prints only the command name with no paths.

Check multiple commands at once by listing them as arguments:

bashwhereis netcat uptime

To see exactly which directories whereis searches, use -l:

bashwhereis -l

These search paths are NOT the same as $PATH. If whereis cannot find a command you know is installed, -l shows whether its location is covered.

Filter Results by Type: Binary, Source, and Man Pages

Limit output to one type with:

  • -b – binary only
  • -m – man page only
  • -s – source files only
bashwhereis -b ping      # binary only: /bin/pingwhereis -m bash      # man page path only

When you only need the binary path, which or type are more focused. which searches $PATHwhereis -b searches the hard-coded system paths, they may return different results depending on how the command is installed.

Limit Search Paths and Find Unusual Entries

Use -B-M, or -S to restrict the directories whereis searches. The -f flag must come after the directory list to mark where the filenames begin:

bashwhereis -b -B /bin -f cp

Output: cp: /bin/cp

The -f flag is required. Omitting it causes an error.

The -u option finds “unusual” commands — those missing one or more of the requested file types. Use it to find commands in a directory that have no matching man page:

bashcd /binwhereis -m -u *

The * expands to all filenames in /binwhereis checks each one and reports those with no man page entry.

Use whereis command for a three-type lookup, -b/-m/-s to narrow by type, and -m -u * to audit a directory for commands missing man pages. Leave a comment below if you run into any issues.