The locate command for Linux commands

Source: Internet
Author: User
Tags rsyslog

1.locate

The locate command is a file search command that searches faster than the find command because it does not search for a specific directory.

Instead, it searches for a database that contains all the local file information. The Linux system automatically creates this database,

and automatically updated every day, so use locate this command to find the latest changed files. To avoid this situation

You can manually update the database by using the UpdateDB command before using locate.

Command format:

Locate [file name]

#Example01 add Index.hml under the Var directory

[Email protected]_81_181_centos/]# Locate index.html/usr/share/doc/html/index.html/usr/share/doc/ cyrus-sasl-lib-2.1.23/index.html/usr/share/doc/db4-utils-4.7.25/utility/index.html/usr/share/doc/gamin-0.1.10/ index.html/usr/share/doc/python-babel-0.9.4/doc/index.html/usr/share/doc/python-babel-0.9.4/doc/api/ Identifier-index.html/usr/share/doc/python-babel-0.9.4/doc/api/index.html/usr/share/doc/python-babel-0.9.4/doc /api/since-index.html/usr/share/doc/python-iniparse-0.3.1/index.html/usr/share/doc/python-jinja2-2.2.1/ext/ django2jinja/templates/index.html/usr/share/doc/python-jinja2-2.2.1/html/genindex.html/usr/share/doc/ python-jinja2-2.2.1/html/index.html/usr/share/doc/python-pygments-1.1.1/docs/build/index.html/usr/share/doc/ Rsyslog-5.8.10/index.html/usr/share/doc/udev-147/writing_udev_rules/index.html

Found and did not search to/var/index.html

Use the UpdateDB command:

[Email protected]_81_181_centos/]# updatedb[[email protected]_81_181_centos/]# Locate index.html/usr/share/doc/ html/index.html/usr/share/doc/cyrus-sasl-lib-2.1.23/index.html/usr/share/doc/db4-utils-4.7.25/utility/ Index.html/usr/share/doc/gamin-0.1.10/index.html/usr/share/doc/python-babel-0.9.4/doc/index.html/usr/share/doc /python-babel-0.9.4/doc/api/identifier-index.html/usr/share/doc/python-babel-0.9.4/doc/api/index.html/usr/ Share/doc/python-babel-0.9.4/doc/api/since-index.html/usr/share/doc/python-iniparse-0.3.1/index.html/usr/share /doc/python-jinja2-2.2.1/ext/django2jinja/templates/index.html/usr/share/doc/python-jinja2-2.2.1/html/ Genindex.html/usr/share/doc/python-jinja2-2.2.1/html/index.html/usr/share/doc/python-pygments-1.1.1/docs/build /index.html/usr/share/doc/rsyslog-5.8.10/index.html/usr/share/doc/udev-147/writing_udev_rules/index.html/var/ Index.html

2. After you create a file in some directories and then update the database, you cannot use the Locate command to find

The reason is that the system has set some limits in the configuration file for updating the database, so the search is not available, so enter the following command to see:

[[Email protected]_81_181_centos lib]# vi/etc/updatedb.conf prune_bind_mounts = "Yes" prunefs = "9p AFS anon_inodefs Auto AutoFS bdev binfmt_misc cgroup cifs coda Configfs cpuset debugfs devpts ecryptfs exofs fuse fusectl GFs gfs2 hugetlbfs ino  TIFYFS iso9660 JFFS2 Lustre Mqueue ncpfs NFS nfs4 nfsd pipefs proc Ramfs rootfs rpc_pipefs securityfs selinuxfs SFS sockfs Sysfs Tmpfs ubifs udf usbfs "prunenames =". Git. Hg. svn "prunepaths ="/afs/media/net/sfs/tmp/udev/var/cache/ccache /var/spool/cups/var/spool/squid/var/tmp "

prune_bind_mounts = "Yes" indicates that search restrictions are turned on, and if ' no ' means no search restrictions are turned on;
Prunefs = A file system that does not search when searching;
Prunenames = The file type that is not searched when searching;
Prunepaths = The path that is not searched when searching;
Not only locate commands follow search restrictions, Whereis and which also follow

The locate command for Linux commands

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.