The whereis command can only be used for searching program names, and only binary files (parameter-B), man description files (parameter-m), and source code files (parameter-S) can be searched ). If the parameter is omitted, all information is returned.
Compared with find, whereis searches very quickly, because the Linux system records all files in the system in a database file, when whereis and the locate described below are used, data will be searched from the database, instead of searching through the hard disk like the find command, which will naturally be very efficient.
However, this database file is not updated in real time. It is updated once a week by default. Therefore, when we use whereis and locate to find the file, we sometimes find the deleted data, you can't find the file you just created because the database file is not updated.
1. Command Format:
Whereis [-bmsu] [BMS directory name-F] File Name
2. command functions:
The whereis command locates executable files, source code files, and help files in the file system. The attributes of these files should belong to the original code, binary file, or help file. The whereis Program also provides the ability to search for source code, specify a backup search path, and search for unusual items.
3. command parameters:
-B. Locate the executable file.
-M: locate the Help file.
-S: locate the source code file.
-U searches for executable files, source code files, and help files in the default path.
-B specifies the path to search for executable files.
-M specifies the path for searching the Help file.
-S specifies the path to search for source code files.
4. Example:
Instance 1: Find all files related to the ** File
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
Note:
Tomcat is not installed and cannot be found. Many related files are found during SVN installation.
Instance 2: Search for binary files 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 ~] #
Note:
Whereis-m svn finds the path of the instruction document, and whereis-s SVN finds the source file.