Linux Basic Command (--locate) command

Source: Internet
Author: User

Locate allows users to quickly search the file system for specific files. The method is to set up a database that includes all the file names and paths within the system, and then simply query the database when looking for it, rather than actually going deep into the file system.

1. Command format

Locate [select parameters] [style]
2. Command function

The locate command can quickly locate the file when searching for a database, the database is updated by the UpdateDB program, UpdateDB is created periodically by Cron Daemon, and the locate command searches the database

is faster than the entire data from the hard disk search, but the worse is the locate found if the file was recently established or just renamed, may not be found, in the default value, UpdateDB per day

Will run once, can be modified by the crontab to update the set value. (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, and can use special characters (such as "*" or

”?” And so on) to specify the template style, as specified by Kcpa*ner, locate will find all files or directories that start with a string of KCPA and end with NER, such as the name Kcpartner if the directory name

For Kcpa_ner, all files, including subdirectories, are listed under this directory.

The locate command is similar to find finding files, but locate is to create an index database of all the files and directory data on the hard drive through the update program, which is directly found when executing loacte.

Index, the query is faster, the index database is generally managed by the operating system, but 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.
-1 if it is 1. The security mode is started. In safe mode, the user does not see files that the permissions cannot see. This slows down because the locate must get access to the file in the actual file system.
-F excludes specific file systems, for example, we have no reason to put the files in the proc file system in the database.
-Q Quiet mode, no error message is displayed.
-N displays at most x outputs.
-R uses the normal arithmetic to do the searching condition.
-o Specifies the name of the data inventory.
-d Specifies the path of the repository
-H Display Auxiliary message
-V Displays the version message of the program
4. Use Example
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

Example 3:Search the ETC directory for all files starting with M
Command:locate/etc/m

Linux Basic Command (--locate) command

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.