TechTorch

Location:HOME > Technology > content

Technology

What is the whereis Command in Linux?

April 10, 2025Technology2748
What is the Whereis Command in Linux? In the Unix and Linux environmen

What is the Whereis Command in Linux?

In the Unix and Linux environments, the whereis command is a powerful tool that helps users locate the binary files, source code, and manual pages (man pages) associated with a specific command or filename. This article will explain the use of the whereis command, its features, and provide examples to illustrate its functionality.

Understanding the whereis Command

The whereis command is primarily used for finding the locations of binary files, source files, and man pages. When you need to know the paths to these files for a particular command, the whereis command can save you a lot of time and effort.

Basic Usage

To use the whereis command, you simply need to specify the command or filename you are interested in. For example, if you want to find the locations of the ls command, you can use:

:~ whereis ls

The output will provide information about the locations of the binary file, source files, and man pages for the ls command:

ls: /usr/bin/ls /usr/share/man/man1/ls.1.gz

Example: Using whereis with Docker

Let's see another example using the docker command:

:~ whereis docker

This command will output the following:

docker: /usr/bin/docker /etc/docker  /usr/share/man/man1/docker.1.gz

Command Options and Flags

The whereis command offers several options and flags that can be used to refine the search. Here are the available options and their descriptions:

-b: Search only for binaries. -B dirs: Define a custom path for finding binary files. -m: Search only for man and info files. -M dirs: Define a custom path for finding man and info files. -s: Search only for source files. -S dirs: Define a custom path for finding source files. -f: Terminate the custom paths argument list. -u: Search for unusual entries. -l: Display the effective lookup paths used by the command. -h --help: Display the help information. -V --version: Display the version of the whereis command.

Example: Using Options with whereis

To illustrate the use of options, let's search for man pages and source code for the ls command using the -m and -s flags:

:~ whereis -m -s ls

This command will focus on searching for man and source files:

ls: /usr/share/man/man1/ls.1.gz /usr/src/linux-4.15.0/include/generated/utsrelease.h:/usr/src/linux-4.15.0/include/generated/uapi/utsrelease.h

Conclusion

The whereis command is an essential tool in a Linux environment, providing quick access to binary files, source code, and man pages. Understanding how to use this command effectively can save you valuable time when working with the command line.