Linux whereis Command
The Linux whereis command is used to locate files.
This command searches specific directories for files that match the criteria. These files should be source code, binary files, or help files.
This command is only used to find binary files, source code files, and man pages. For locating general files, the locate command should be used.
Syntax
whereis [-bfmsu][-B <directories>...][-M <directories>...][-S <directories>...][files...]
Parameters:
-
-b: Only search for binary files.
-B<directories>: Only search for binary files in the specified directories.
-f: Do not display the path names before the file names.
-m: Only search for manual files.
-M<directories>: Only search for manual files in the specified directories.
-s: Only search for source code files.
-S<directories>: Only search for source code files in the specified directories.
-u: Search for files that do not include the specified type.
Example
To view the location of the "bash" command using the "whereis" command, enter the following command:
$ whereis bash
The output information after executing the above command is as follows:
bash: /bin/bash /etc/bash.bashrc /usr/share/man/man1/bash.1.gz
Note: The output information from left to right includes the queried program name, bash path, and bash man page path.
If the user needs to query binary files or help files separately, use the following commands:
$ whereis -b bash
$ whereis -m bash
The output information is as follows:
$ whereis -b bash # Displays the binary program of the bash command
bash: /bin/bash /etc/bash.bashrc /usr/share/bash # Address of the binary program of the bash command
$ whereis -m bash # Displays the help file of the bash command
bash: /usr/share/man/man1/bash.1.gz # Address of the help file of the bash command