The whereis command can only be used for program name search, and only searches for binary files (parameter-b), man description files (parameter-m) and source code files (parameter-s). If the parameters are omitted, all information is returned.
Compared with find, whereis searching is very fast, because the Linux system will record all files in the system in a database file. When using whereis and the locate that will be introduced below, data will be found from the database. Instead, searching by traversing the hard disk like the find command, it will naturally be very efficient.
However, the database file is not updated in real time. By default, it is updated once a week. Therefore, when we use whereis and locate to find files, we sometimes find the deleted data, or just created the file but cannot find it. The reason is that the database file has not been updated.
1. Command format:
whereis [-bmsu] [BMS Directory name -f ] file name
2. Command function:
The whereis command locates the location of executable files, source code files, and help files in the file system. The properties of these files should belong to the original code, binary file, or help file. The whereis program also has the ability to search source code, specify alternative search paths, 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 Search for other files except executable files, source code files, and help files under the default path.
-B Specifies the path to search for the executable file.
-M Specifies the path to search for help files.
-S Specifies the path to search for source code files.
4. Examples of usage:
Example 1:Find all the files related to ** files
Order:
whereis svn
Output:
[root@localhost ~]# whereis tomcat tomcat: [root@localhost ~]# whereis svn svn: /usr/bin/svn /usr/local/svn /usr/share/man/man1/svn.
illustrate:
Tomcat is not installed, so I can't find it. I found a lot of related files in the svn installation.
Example 2:Find only binary files
Order:
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. [root@localhost ~]# whereis -s svn svn: [root@localhost ~]#
illustrate:
whereis -m svn Find the document path of the description, whereis -s svn Find the source source file.
The above is all the content of this article. I hope it will be helpful to everyone's study and I hope everyone will support me more.