an introduction
1. Grammar
locate filename
Search by filename in the backend database for faster searches.
2. The background database searched by the locate command
/var/lib/mlocate
The database is updated once a day by default.
3. Force database update
updatedb
4. Advantages
quick
5. Disadvantages
Only search by file name
Two actual combat
[root@localhost test]# ls
abc abc.soft
[root@localhost test]# updatedb
[root@localhost test]# locate abc.soft
/root/test/abc.soft
[root@localhost test]# touch abcdef
[root@localhost test]# locate abcdef
[root@localhost test]# updatedb
[root@localhost test]# locate abcdef
/root/test/abcdef
[root@localhost test]# locate mlocate
/etc/cron.daily/mlocate
/usr/share/doc/mlocate-0.26
- ......
/var/lib/mlocate
/var/lib/mlocate/mlocate.db
/var/lib/mlocate/mlocate.db.FhTi2M
Three /etc/updatedb.conf configuration file
lolate whereis which all follow this rule.
Four actual combat
[root@localhost test]# touch /tmp/cakin2425
[root@localhost test]# updatedb
[root@localhost test]# locate cakin2425
[root@localhost test]# cat /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 fuse.sshfs fusectl gfs gfs2 hugetlbfs inotifyfs 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 /mnt /net /sfs /tmp /udev /var/cache/ccache /var/lib/yum/yumdb /var/spool/cups /var/spool/squid /var/tmp"