Linux common commands: whereis command


  The whereis command can only be used to search for program names, and only search binary files (parameter -b), man specification files (parameter -m) and source code files (parameter -s). If the parameter is omitted, all information is returned.

  Compared with find, whereis is very fast to find, because the Linux system records all the files in the system in a database file. When using whereis and locate, which will be introduced below, it will find data 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. It is updated once a week by default. Therefore, when we use whereis and locate to find files, we sometimes find data that has been deleted, or just create a file, but cannot find it. The reason It is because the database file has not been updated. 

 

1. Command format:

whereis [-bmsu] [BMS directory name -f ] file name

2. Command function:

  The whereis command is used to locate executable files, source code files, and help files in the file system. The attributes of these files should belong to source 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 locate the executable.

-m Locate help files.

-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.

4. Example of use:

Example 1: Find all files related to the ** file

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.1.gz

 illustrate:

tomcat is not installed, can't find it, svn installation found a lot of related files

Example 2: Find out 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.1.gz

[root@localhost ~]# whereis -s svn

svn:

[root@localhost ~]#

illustrate:

  w hereis -m svn find out the documentation path, whereis -s svn find the source file.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325119148&siteId=291194637