A Linux Command (17) every day: whereis command

Source: Internet
Author: User

The whereis command can only be used for searching program names, and only binary files (parameter-B), man description files (parameter-m), and source code files (parameter-S) can be searched ). If the parameter is omitted, all information is returned.

Compared with find, whereis searches very quickly, because the Linux system records all files in the system in a database file, when whereis and the locate described below are used, data will be searched from the database, instead of searching through the hard disk like the find command, which will naturally be very efficient.

However, this 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 the file, we sometimes find the deleted data, you can't find the file you just created because the database file is not updated.

1. Command Format:

Whereis [-bmsu] [BMS directory name-F] File Name

2. command functions:

The whereis command locates executable files, source code files, and help files in the file system. The attributes of these files should belong to the original code, binary file, or help file. The whereis Program also provides the ability to search for source code, specify a backup search path, 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 searches for 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 for searching the Help file.

-S specifies the path to search for source code files.

4. Example:

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

Note:

Tomcat is not installed and cannot be found. Many related files are found during SVN installation.

Instance 2: Search for binary files only

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

Note:

Whereis-m svn finds the path of the instruction document, and whereis-s SVN finds the source file.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.