Open In App

whereis command in Linux with Examples

Last Updated : 03 Aug, 2022
Like Article

whereis command is used to find the location of source/binary file of a command and manuals sections for a specified file in Linux system. If we compare whereis command with find command they will appear similar to each other as both can be used for the same purposes but whereis command produces the result more accurately by consuming less time comparatively. whereis doesn’t require any root privilege to execute in any RHEL/CentOS 7

The supplied names are first removed from leading pathname/directory components and any (single) trailing extension of the form .ext, for example, .c. Prefixes of s. resulting from use of source code control are also dealt with. whereis then attempts to locate the desired program in a list of standard Linux directories. 

Points to be kept on mind while using whereis command:

  • Since whereis command uses chdir(change directory 2V) to give you the result in fastest possible way, the pathnames given with the -M, -S, or -B must be full and well defined i.e. they must begin with a `/‘ and should be a valid path that exist in the system’s directories, else it exits without any valid result.
  • whereis command has a hard-coded(code which is not dynamic and changes with specification) path, so you may not always find what you’re looking for.


whereis [options] filename...

Example 1: Let’s say, we want to find the location of apropos command then we need to execute the following command in the terminal: 


Example 2: To find the location of lshw command.



  • -b : This option is used when we only want to search for binaries. 
    Example: To locate binary of a Linux command let’s say gunzip. 
  • -m : This option is used when we only want to search for manual sections. Example: To locate man page of false command.
  • -s : This option is used when we only want to search for sources.
  • -u: This option search for unusual entries. A source file or a binary file is said to be unusual if it does not have any existence in system as per [-bmsu] described along with “–u”. Thus `whereis -m -u *‘ asks for those files in the current directory which have unusual entries. Example: To display the files in the current directory which have no documentation file. 
  • -B : This option is used to change or otherwise limit the places where whereis searches for binaries. Example: To locate binary of lesspipe in the path, /bin
  • -M : This option is used to change or otherwise limit the places where whereis searches for manual sections. Example: To check man page of intro that is only in a specific location i.e. /usr/share/man/man1.
  • -S : This option is used to change or otherwise limit the places where whereis searches for sources. Example: To Find all files in /usr/bin which are not documented in /usr/man/man1 with source in /usr/src.
  • -f : This option simply terminate the last directory list and signals the start of file names. This must be used when any of the -B, -M, or -S options are used.
  • -V: Displays version information and exit.
  • -h: Displays this help and exit.

Previous Article
Next Article

Similar Reads

Ccat – Colorize Cat Command Output command in Linux with Examples
ccat is a command-line tool for Linux and OSX, which is similar to the cat command in Linux. But the difference between cat and ccat is that the ccat shows the content of the file with the syntax highlighted. Currently, ccat supports the following programming languages. JavaScriptJavaRubyPythonGoCJSONInstallation of Ccat First, we are going to see
2 min read
How to Display Command History in Linux | history Command
The command-line interface in Linux provides powerful tools for users, and mastering command history is essential for efficient navigation and retrieval of previously executed commands. The history command is a valuable utility that allows users to view and search through their command history. In this comprehensive guide, we will explore the vario
4 min read
select command in Linux with examples
select command in Linux is used to create a numbered menu from which a user can select an option. If the user enters a valid option then it executes the set of command written in select block and then ask again to enter a number, if a wrong option is entered it does nothing. If user enters nothing and simply press 'enter' the option menu gets print
1 min read
ZIP command in Linux with examples
ZIP is a compression and file packaging utility for Unix. Each file is stored in a single .zip {.zip-filename} file with the extension .zip. Zip is used to compress files to reduce file size and is also used as a file package utility. Zip is available in many operating systems like Unix, Linux, windows, etc.If you have limited bandwidth between two
7 min read
atrm command in Linux with examples
atrm command is used to remove the specified jobs. To remove a job, its job number is passed in the command. A user can only delete jobs that belong to him. Only superuser can delete any job even if that belongs to another user. Syntax: atrm [-V] job [job...] Options: -V : Used to print the version number atrm -V job : Job number of the job which i
1 min read
comm command in Linux with examples
comm compare two sorted files line by line and write to standard output; the lines that are common and the lines that are unique. Suppose you have two lists of people and you are asked to find out the names available in one and not in the other, or even those common to both. comm is the command that will help you to achieve this. It requires two so
5 min read
cmp Command in Linux with examples
cmp command in Linux/UNIX is used to compare the two files byte by byte and helps you to find out whether the two files are identical or not. When cmp is used for comparison between two files, it reports the location of the first mismatch to the screen if difference is found and if no difference is found i.e the files compared are identical.cmp dis
5 min read
expand Command in LINUX with examples
Whenever you work with files in LINUX there can be a situation when you are stuck with a file containing many tabs and whatever you need to do with a file requires that file with no tabs but with spaces. In this situation, the task looks quite simple if you are dealing with a small file but what if the file you are dealing with is very big or you n
3 min read
df Command in Linux with examples
There might come a situation while using Linux when you want to know the amount of space consumed by a particular file system on your LINUX system or how much space is available on a particular file system. LINUX being command friendly provides a command line utility for this i.e df command that displays the amount of disk space available on the fi
8 min read
tee command in Linux with examples
tee command reads the standard input and writes it to both the standard output and one or more files. The command is named after the T-splitter used in plumbing. It basically breaks the output of a program so that it can be both displayed and saved in a file. It does both the tasks simultaneously, copies the result into the specified files or varia
2 min read
Article Tags :