One linux Command (18) every day: locate command

Source: Internet
Author: User
Tags touch command

One linux Command every day (18): locate command link: One linux Command every day (1): ls command OS /210210/163049.html#linuxlinuxcommand every day (2): cd command serial (3 ): pwd command Export (4): mkdir command OS /201210/1620.3.html#a linuxcommand every day (5): rm command Export (6): rmdir command OS /201210/1640 17. html; one linux Command every day (7): mv command running (8): cp command OS /201210/163164.html#a linuxcommand every day (9): touch command running (10): cat command running (11 ): nl command OS /201211/165990.htmla linuxcommand every day (12): more command OS /201211/165994.htmllinuxcommand every day (1 3): less command running (14): head command OS /201211/166191.htmla linuxlinuxcommand every day (15): tail command running (16): which command running (17 ): the whereis command OS /201211/168893.html locate allows users to quickly search for a specified file in the file system. The method is to first create a database that includes the names and paths of all files in the system. Then, you only need to query the database when searching, instead of going into the file system. In general distribution, database creation is automatically executed in crontab. 1. command Format: Locate [select parameter] [style] 2. command function: the locate command can be used to quickly find files when searching for a database. The database is updated by the updatedb program, and the updatedb is periodically created by the cron daemon, the locate command is faster than searching for data from the entire hard disk, but worse is that the files found by the locate are created recently or renamed, it may not be found. In the specified value, updatedb runs once a day. You can modify crontab to update the set value. (Etc/crontab) locate is used to search for qualified files. It stores the files and directory names in the database to find files or directories that meet the template style conditions, special characters (such as "*" or "?") To specify the template style. For example, if you specify the template as the kcpa * ner, locate will find all the files or directories whose start string is kcpa and end with the ner, for example, if the directory name is kcpartner and the directory name is kcpa_ner, all files including subdirectories in the directory are listed. The locate command is similar to the find file query function. However, the locate program uses the update program to create an index database for all files and directories on the hard disk. When executing the loacte command, it directly finds the index, the query speed is faster. The index database is generally managed by the operating system, but you can also directly issue an update command to force the system to immediately modify the index database. 3. Command Parameter:-e will be excluded from the search range. -1 if it is 1. The security mode is enabled. In security mode, users do not see files that cannot be viewed by permissions. This slows down because the locate must obtain the permission information for the file in the actual file system. -F exclude a specific file system. 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 up to n outputs. -R uses the regular formula for search conditions. -O specifies the data inventory name. -D specifies the path of the database-h displays the auxiliary message-V displays the version information of the program 4. use instance: instance 1: Find all pwd-related file commands: locate pwd output: peida-VirtualBox ~ # Locate pwd/bin/pwd/etc /. pwd. lock/sbin/unix_chkpwd/usr/bin/pwdx/usr/include/pwd. h/usr/lib/python2.7/dist-packages/twisted/python/fakepwd. py/usr/lib/python2.7/dist-packages/twisted/python/fakepwd. pyc/usr/lib/python2.7/dist-packages/twisted/python/test/ lib/syslinux/pwd. c32/usr/share/help/C/empathy/irc-join-pwd. Page/usr/share/help/ca/empathy/ share/help/el/empathy/ instance 2: search all files starting with sh in the etc directory. Command: locate/etc/sh output: peida-VirtualBox ~ # Locate/etc/sh/etc/shadow-/etc/shellspeida-VirtualBox ~ # Instance 3: search for all files starting with m in the etc directory. Command: locate/etc/m output: peida-VirtualBox ~ # Locate/etc/m/etc/magic. mime/etc/mailcap. order/etc/manpath. config/etc/mate-settings-daemon

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: 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.