How To

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.

Cyber Defence

Recent Posts

What I Wish I Knew Before Learning Malware Analysis and Reverse Engineering

When I first started learning malware analysis and reverse engineering, I thought the hardest part…

3 days ago

git fetch vs git pull: How They Work and When to Use Each

Both git fetch and git pull talk to a remote repository, but they do very different things to your…

2 weeks ago

git cherry-pick Command: Apply Commits from Another Branch

Sometimes the change you need already exists, just on the wrong branch. A hotfix lands…

2 weeks ago

Best Email APIs for Secure Business Email: Why Developers Are Moving Beyond SMTP

Email is still one of the most important communication channels inside modern applications. Password resets,…

2 weeks ago

Nginx Commands in Linux: Start, Stop, Reload, Test, and Log

Nginx is a high-performance web server and reverse proxy trusted by some of the largest…

2 weeks ago

ufw Command in Linux: Manage Firewall Rules with Examples

ufw (Uncomplicated Firewall) sits on top of iptables (or nftables on newer systems) and replaces…

2 weeks ago