In Linux, the whereis command is used to locate the location of executable files, source code files, and help files in the file system. The syntax is "whereis [option parameter] [BMS directory name -f ] file name". The whereis command can only be used to search for program names, and only searches binary files (parameter "-b"), man description files (parameter "-m") and source code files (parameter "-s"); if the parameters are omitted, All information is returned.
#The operating environment of this tutorial: linux7.3 system, Dell G3 computer.
The whereis command in Linux is used to locate the location of executable files, source code files, and help files in the file system. The attributes of these files should belong to original code, binary files, or help files.
whereis The program also has the ability to search source code, specify alternative search paths, and search for unusual items.
whereis command uses
whereis command can only be used to search for program names, and only searches for binary files (parameter -b), man Description files (parameter -m) and source code files (parameter -s). If parameters are omitted, all information is returned.
Compared with find, whereis search speed is very fast. This is because the Linux system will record all files in the system in a database file. When using whereis, the data will be searched from the database. Instead of searching by traversing the hard disk like the find command, the efficiency will naturally be very high.
However, the database file is not updated in real time. By default, it is updated once a week. Therefore, when we use whereis to search for files, we sometimes find data that has been deleted, or the file has just been created, but cannot It was found that the reason was that the database file had not been updated.
Linux whereis command detailed explanation
Function
The whereis command is used to find files.
Syntax
whereis [-bmsu] [BMS 目录名 -f ] 文件名
Parameters
Parameters | Description |
---|---|
-b | Locate the executable file. |
-m | Locate the help file. |
-s | Locate source code files. |
-u | Search for files other than 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 to search for help files. |
-S | Specifies the path to search for source code files. |
Common examples of whereis command
Find the location of the cd command
whereis cd
Find out all files related to tomcat and svn
whereis tomcat whereis svn
Explanation: tomcat is not Installation, cannot be found, svn installation found many related files
Only binary files were found
# whereis -b svn svn: /usr/bin/svn /usr/local/svn # whereis -m svn svn: /usr/share/man/man1/svn.1.gz # whereis -s svn svn:
Explanation: whereis -m svn finds the documentation path, and whereis -s svn finds the source file.
Related recommendations: "Linux Video Tutorial"
The above is the detailed content of How to use linux whereis command. For more information, please follow other related articles on the PHP Chinese website!