-bash: locate: command not found

部分版本的linux系统使用locate快速查找某文件路径会报以下错误:

[html] view plain copy
 
  1. -bash: locate: command not found  

-bash: locate: command not found

其原因是没有安装mlocate这个包

安装:yum  -y install mlocate

安装完再尝试用locate定位内容,发现依然不好使,报了新的错误:

[html] view plain copy
 
  1. locate: can not stat () `/var/lib/mlocate/mlocate.db': No such file or directory  

-bash: locate: command not found

原因是安装完后没有更新库

更新库:updatedb

-bash: locate: command not found