The whereis
command can only be used for program name searching, and only searches binary files (argument -b), man description files (argument -m) and source files (argument -s). If the argument is omitted, all information is returned.
Compared to find
, whereis
is very fast because linux records all files on the system in a database file, and when using whereis
and locate
, which will be described below, the data is found from the database rather than by traversing the hard disk as in the find
command, which is naturally very efficient.
However, the database file is not updated in real time, but once a week by default. Therefore, when we use whereis
and locate
to find files, we sometimes find data that has been deleted, or we just create a file, but we can’t find it because the database file has not been updated.
1. Command format.
whereis [-bmsu] [BMS directory name -f ] filename
2. Command function.
The whereis
command is to locate the location of executable files, source code files, and help files in the file system. The properties of these files should belong to either the original code, binary files, or help files. The whereis
program also has the ability to search source code, specify alternate search paths, and search for unusual items.
3. Command parameters.
-b Locates the executable file.
-m Locates the help file.
-s Locates the source code file.
-u Searches for files other than executables, source code files, and help files in the default path.
-B Specifies the path to search for executable files.
-M Specifies the path to search for help files.
-S Specifies the path to search for source code files.
4. Examples of use.
Example 1: Find all the files related to ** files
command.
whereis svn
Output.
[root@localhost ~]# whereis tomcat
tomcat:
[root@localhost ~]# whereis svn
svn: /usr/bin/svn /usr/local/svn /usr/share/man/man1/svn.1.gz
Description.
tomcat is not installed, can’t find it, svn installation found a lot of related files
Example 2: Find the binary file only
command.
whereis -b svn
Output.
[root@localhost ~]# whereis -b svn
svn: /usr/bin/svn /usr/local/svn
[root@localhost ~]# whereis -m svn
svn: /usr/share/man/man1/svn.1.gz
[root@localhost ~]# whereis -s svn
svn:
[root@localhost ~]#
Description.
whereis -m svn
to find out the path to the documentation, whereis -s svn
to find the source source file.
Reference: