Linux how to use the whereis command to quickly find the file

  

Linux whereis command and find command are a bit similar, whereis command finds faster, but can only find the program name, the following with the small series to understand the specific use of the whereis command Let's go.

whereis command searches only binary files (parameter -b), man documentation (parameter -m) and source code files (parameter -s). If the parameter is omitted, all information is returned.

Compared with find, whereis lookup is very fast, this is because the Linux system will record all the files in the system in a database file, when using whereis and the locate below will be Finding data from the database, rather than looking through the hard disk, like the find command, is naturally very efficient.

But 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 created a file. I can't find it 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 locates the executable file, source code file, and help file in the file system. The attributes of these files should belong to the original code, binary file, or help file. The whereis program also has the ability to search for source code, specify alternate search paths, and search for unusual items.

3. Command parameters:

-b Locate the executable file.

-m Locate the help file.

-s Position the source code file.

-u Searches 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:

Instance 1: Find the 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

Description:

tomcat is not installed, can not find out, svn installation found a lot of related documents < Br>

Instance 2: Find only binary files

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 ~]#

Description:

whereis -m svn Isolated documentation path, whereis -s svn Source source file.

The above is the usage of the whereis command under Linux. The conditions of the whereis command search are relatively limited. If you only search for the program name, using the whereis command is very fast.

Copyright © Windows knowledge All Rights Reserved