locate也是用于查找文件的命令,与find类似,但是比find快很多,因为该命令会自动找到数据库/var/lib/mlocate/mlocate.db
这个文件是Linux自动记录我们系统的文件,系统会定期的更新该文件
我们来试一下该命令:
一、准备工作、
安装locate,因为Linux自带是没有这个的
yum install mlocate
二、使用locate
[root@hadoop001 /]# locate /etc/yu
/etc/yum
/etc/yum.conf
/etc/yum.conf.rpmnew
/etc/yum.repos.d
/etc/yum/pluginconf.d
/etc/yum/protected.d
/etc/yum/vars
/etc/yum/version-groups.conf
/etc/yum/pluginconf.d/fastestmirror.conf
/etc/yum.repos.d/10gen.repo
/etc/yum.repos.d/CentOS-Base.repo
/etc/yum.repos.d/epel-testing.repo
/etc/yum.repos.d/epel.repo
/etc/yum.repos.d/epel.repo.rpmnew
/etc/yum.repos.d/erlang_solutions.repo
/etc/yum.repos.d/kernel6.repo
/etc/yum.repos.d/remi.repo
/etc/yum.repos.d/rpmforge.repo
注:我们在平时很可能会遇到,locate查到已经删除或者是刚建的文件查不到,原因是数据库文件/var/lib/mlocate/mlocate.db没有更新,因此,我们可以使用这个命令:
updatedb