whereis: command not found

The whereis command is used to display various details associated with a command. For example, when entering whereis ls the following output is displayed:ls: /bin/ls /usr/share/man/man1/ls.1.gz /usr/ share/man/man1p/ls.1p.gz.

Where /bin/ls indicates the location of the ls command and /usr/ share/man/man1/ls.1.gz /usr/share/man/man1p/ls.1p.gz indicates the location of the man pages for the ls command.

Syntax

The syntax of the whereis command is:

$ whereis [options] [directory name] {file name}

whereis Command Options

The whereis command has several options, as described in the following table.

Option Description
-b Search only for binaries.
-m Search only for manual sections.
-s Search only for sources.
-u Search for unusual entries.

If you encounter below error while running the whereis command:

whereis: command not found

you may try installing below package as per your choice of distribution:

Distribution Command
OS X brew install util-linux
Debian apt-get install util-linux
Ubuntu apt-get install util-linux
Alpine apk add util-linux
Arch Linux pacman -S util-linux
Kali Linux apt-get install util-linux
CentOS yum install util-linux
Fedora dnf install util-linux
Raspbian apt-get install util-linux

whereis Command Examples

1. Locate binary, source and man pages for ssh:

# whereis ssh

2. Locate binary and man pages for ls:

# whereis -bm ls

3. Locate source of gcc and man pages for Git:

# whereis -s gcc -m git

4. Locate binaries for gcc in `/usr/bin/` only:

# whereis -b -B /usr/bin/ -f gcc

5. Locate unusual binaries (those that have more or less than one binary on the system):

# whereis -u *

6. Locate binaries that have unusual manual entries (binaries that have more or less than one manual installed):

# whereis -u -m *

Conclusion

The whereis command attempts to locate the given files by searching a hardcoded list of directories. It can find executables, documentation, and source code. whereis is somewhat quirky because its list of directories might not include the ones you need.

Related Post