Three search commands in linux

Source: Internet
Author: User

Three search commands in linux

There are many commands in linux to view the file path. Here we will summarize them a little.

1. find command

The find command should be the most familiar SEARCH Command and the most powerful search command in linux. It can find any file you want in the specified directory. Usage:

Find <specified directory> <specified condition> <specified action>

If no parameter is added, the current directory and its sub-directories are searched, and no results are filtered, and they are displayed on the screen. Example:

Find.-name test indicates searching for the file named test in the current directory.

Find/home/xiang-amin-2 find the files that have been accessed in the specified directory in the last two minutes

There are many other conditions for specifying the find statement. For more information, see man.

2. The essence of locate is find-name, but the execution efficiency of locate is much faster than that of the find command because its search is not directory-based, instead, search for the database file/var/lib/locatedb. To prevent too many files from being listed, it is generally used with the grep command to find the files in a specific directory. The file is automatically created and updated in linux. To avoid searching for newly created files, run the updatedb command before using it. Locate usage:

Find <File Name>

Example: locate test to find all files starting with test.

3, whereis

This command can only be used for binary files, man files, and source code files.-B indicates binary executable files,-m indicates man files, and-s indicates source files.

Location of all pwd files in whereis pwd

In addition, which and type also have the file search function in some cases. Because it is not very common in practice, it is not described here.

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.