Linux uses the locate command to locate files

Source: Internet
Author: User

Find command

Many Linux users like to use the Find command to find files, 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 both T Heir 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 packages installed, and most Linux distributions now have this package integrated. If it is not installed, you can access the Mlocate home page (http://carolina.mff.cuni.cz/~trmac/blog/mlocate/) to download the installation. 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 in the background, which contains the index of your file system (this updates the Mlocate database that indexes your files and forks it to the BACKG Round (the ' & ' forks 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. The speed is faster than find, because it reads the index inside the Mlocate database!

Linux uses the locate command to locate files

Related Article

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.