locate 命令

locate 查找包含你想要找的东西

例如:locate  hosts 

[root@master mail]# locate hosts
/etc/hosts
/etc/hosts.allow
/etc/hosts.deny
/etc/selinux/targeted/modules/active/modules/denyhosts.pp
/lib64/security/pam_rhosts.so
/root/.ssh/known_hosts
/usr/share/ghostscript
/usr/share/doc/pam-1.1.1/html/sag-pam_rhosts.html
/usr/share/doc/pam-1.1.1/txts/README.pam_rhosts
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/PER_IP_CONFIG/hosts.allow
/usr/share/ghostscript/conf.d
/usr/share/man/man5/hosts.allow.5.gz
/usr/share/man/man5/hosts.deny.5.gz
/usr/share/man/man5/hosts_access.5.gz
/usr/share/man/man5/hosts_options.5.gz
/usr/share/man/man8/pam_rhosts.8.gz
/usr/share/selinux/devel/include/services/denyhosts.if
/usr/share/selinux/targeted/denyhosts.pp.bz2
/usr/share/vim/vim74/ftplugin/denyhosts.vim
/usr/share/vim/vim74/ftplugin/hostsaccess.vim
/usr/share/vim/vim74/syntax/denyhosts.vim
/usr/share/vim/vim74/syntax/hostsaccess.vim
/var/cache/yum/timedhosts.txt
/var/cache/yum/x86_64/6/timedhosts.txt
[root@master mail]#

安装:

yum -y install mlocate

安装错误:

  

[root@master mail]# locate hosts
locate: can not stat () `/var/lib/mlocate/mlocate.db': 没有那个文件或目录

解决办法:

  updatedb

原文地址:https://www.cnblogs.com/yangxiaochu/p/7221574.html