Linux uses the locate command to locate files

Source: Internet
Author: User

Full-text excerpt translated from: http://linux-blog.org/finding-files-with-locate/

Find command

Many Linux users prefer to find files using the Find command, For example they usually like to do this:

Find/-name ' pattern '

The powerful feature of find is not only used to find files, it can be used to locate more detailed things, such as you want to find in a directory to give its owners and administrators can write permissions ( If you wanted to find files which is writable by B Oth their owner and their group), you can do this:

Find/-perm-444-perm/222! -perm/111

Or you want to see the files that have been modified within the last 24 hours of your download directory,

find/home/user/downloads/-mtime 0

The power of the Find command is not just for finding files, it takes time to search for disks. So is there a quick way to locate it?

Locate command

before using locate, you have to verify that the system has mlocate package, now most Linux distributions are integrated with this package. If not installed, you can access Mlocate home page (http://carolina.mff.cuni.cz/~trmac/blog/mlocate/) download and install. After the download is successfully installed, you need to perform a command for your file system index. Otherwise you'll have to wait until the program is executed automatically.

The root user executes the following command:

UpdateDB &

This command will update your mlocate database, which contains the index of your file system (this updates the Mlocate database that indexes your files and forks it to the background (the ' & ' fo Rks it to the background ).

When this command is done, you can easily use the Locate command:

locate Firefox | Less

This will quickly locate files, directories, and so on for Firefox. Speed is faster than find, because it reads mlocate database !




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.