locate command

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
  1. [root@localhost test]# ls
  2. abc abc.soft
  3. [root@localhost test]# updatedb
  4. [root@localhost test]# locate abc.soft
  5. /root/test/abc.soft
  6. [root@localhost test]# touch abcdef
  7. [root@localhost test]# locate abcdef
  8. [root@localhost test]# updatedb
  9. [root@localhost test]# locate abcdef
  10. /root/test/abcdef
  11. [root@localhost test]# locate mlocate
  12. /etc/cron.daily/mlocate
  13. /usr/share/doc/mlocate-0.26
  14. ......
  15. /var/lib/mlocate
  16. /var/lib/mlocate/mlocate.db
  17. /var/lib/mlocate/mlocate.db.FhTi2M
Three /etc/updatedb.conf configuration file


 
lolate whereis which all follow this rule.
 
Four actual combat
  1. [root@localhost test]# touch /tmp/cakin2425
  2. [root@localhost test]# updatedb
  3. [root@localhost test]# locate cakin2425
  4. [root@localhost test]# cat /etc/updatedb.conf
  5. PRUNE_BIND_MOUNTS ="yes"
  6. 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"
  7. PRUNENAMES =".git .hg .svn"
  8. PRUNEPATHS ="/afs /media /mnt /net /sfs /tmp /udev /var/cache/ccache /var/lib/yum/yumdb /var/spool/cups /var/spool/squid /var/tmp"

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326145746&siteId=291194637