Every day a Linux command (--locate) command

Source: Internet
Author: User

Locate allows users to quickly search the file system for specific files. The method is to establish a database that includes all the file names and paths within the system, and then query the database when looking for it without actually going deep into the file system. In the general ditrtibution, the database is built in the north in the Crontab automatic execution.

1. Command format:

Locate [select parameters] [style]

2. Command function:

The locate command can quickly find the file when searching for the database, the database is updated by the UpdateDB program, UpdateDB is created periodically by Cron Daemon, and the locate command searches the database faster than the data from the entire hard drive. But the disadvantage is that locate found the file if it was recently established or just more, may not find, in the colonization, UpdateDB will run once a day, you can modify the crontab to update the SetPoint (/etc/crontab)

Locate is used to search for eligible files, it will go to the database to store files and directory names, find files or directories that conform to the template style conditions, can use special characters (such as "*", "?"). ") to specify the template style, if the specified template is Kcpa*ner, locate will find all the files or directories that start with a string of KCPA and end with NER, such as Kcpartner if the directory name is Kcpa_ner lists all files in that directory, including subdirectories.

Locate command and find find files similar function, but locate is through the update program to the hard disk of all the file box directory data first set up an index database, in the execution of locate directly to find the index, query faster, the index database is generally managed by the operating system, However, you can also directly release the update to force the system to immediately modify the index database.

3. Command parameters:

-E will be excluded from the scope of the search. Except, it is an abbreviation for this word.

-L If it is L boot Safe mode, in Safe mode, the user will not see the permissions can not see the file, which will slow down, because the locate must go to the actual file system to the file permissions data.

-F excludes specific file systems, for example, we have no reason to put files in the proc file system in the database.

-Q Quiet mode, no error message is displayed. -----This situation to be used in front of the boss's face?

-N displays at most x outputs.

-R use regular formulas to find the conditions.

-o Specifies the name of the data inventory.

-d Specifies the path to the repository. The default is in/var/lib/mlocate/mlocate.db.

-H Displays the auxiliary message.

-V Displays the version message of the program.

4. Usage examples:

Example 1: Find all files related to PWD

Command:

Locate pwd

Example 2: Search all files in the ETC directory that begin with SH

Command:

Locate/etc/sh If you have more specific requirements, you can use the * wildcard character.

  

Every day a Linux command (--locate) command

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.