TrumanWong

whereis

Find binary programs, code and other related file paths

Supplementary instructions

whereis command is used to locate the path of the instruction's binary program, source code file, man manual page and other related files.

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 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 and locate which will be introduced below, 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 and locate to search for files, we sometimes find data that has been deleted, or the file has just been created but cannot be found. The reason It's because the database file has not been updated.

grammar

whereis(option)(parameter)

Options

-b: Only search binary files;
-B<directory>: only search for binary files in the set directory;
-f: Do not display the path name before the file name;
-m: Search only description files;
-M<directory>: only search for description files in the set directory;
-s: Only search original code files;
-S<directory> only searches for original code files in the set directory;
-u: Find files that do not contain the specified type.

Parameters

Instruction name: The instruction name of the binary program, source file and man page to be searched.

Example

Find all relevant files

[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 and cannot be found. The svn installation found many related files.

Find only binary files

[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:

Note: whereis -m svn finds the description document path, and whereis -s svn finds the source file.