Linux five file search commands-which, whereis, find, locate, and type

Source: Internet
Author: User

Commonly used file search commands in Linux include which, whereis, find, locate, and type. The specific usage is not involved here, but the differences between them are compared.


Which: searches for the location of a system command in the path specified by the PATH variable and returns the first search result. When the-a parameter is added, all search results are returned.


Whereis: it can only be used for searching program names. It only searches binary files (-B), description files (-m) in the manual path, and source code files (-S) and other special files (-U ). If the parameter is omitted, all search information is returned. In Linux, all files in the system are recorded in a database file. Whereis uses the database to find data, which is fast and does not actually query the hard disk, saving time.


Find: it takes a long time to directly search for the hard disk. This command can find any file you want!


Locate: The function is equivalent to find-name, but it is much faster than the latter, because the locate command is also used for database search. However, because the database is updated once a day by default, all newly created files may not be found using the locate command. In this case, you need to manually update the database. The command is very simple. Just enter "updatedb!


Type: this command can be used to differentiate whether a command is provided by an independent binary file (builtin) provided by bash or an external bash (provided by other non-bash. If an imperative external command is used, the-p parameter will show that the path of the command serves as which.


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.