centOS locate : command not found 问题解决

时间:2021-08-13 12:58:25

跟随鸟哥的Linux私房菜进行学习的过程中,用locate 查找文件

提示

-bash: locate: command not found

那就先updatedb一下吧

提示

-bash: updatedb: command not found

baidu说updatedb 不能用先要安装 slocate

yum install slocate

提示

找不到 slocate 相应的包

 

 原来是mlocate已经替换slocate了-------

[root@localhost tmp]# yum -y install mlocate

Loaded plugins: fastestmirror              

Loading mirror speeds from cached hostfile 

* base: mirrors.btte.net                  

* extras: mirrors.btte.net                

* rpmforge: ftp.riken.jp                  

* updates: mirrors.btte.net               

Setting up Install Process                 

Resolving Dependencies                     

--> Running transaction check              

---> Package mlocate.i686 0:0.22.2-4.el6 set to be updated

--> Finished Dependency Resolution                       

Dependencies Resolved

==================================================================================================

Package                Arch                Version                     Repository           Size

==================================================================================================

Installing:                                                                                      

mlocate                i686                0.22.2-4.el6                base                 85 k

Transaction Summary

==================================================================================================

Install       1 Package(s)                                                                       

Upgrade       0 Package(s)                                                                       

Total download size: 85 k

Installed size: 273 k   

Downloading Packages:   

mlocate-0.22.2-4.el6.i686.rpm                                              |  85 kB     00:00    

Running rpm_check_debug                                                                          

Running Transaction Test                                                                         

Transaction Test Succeeded                                                                       

Running Transaction                                                                              

  Installing     : mlocate-0.22.2-4.el6.i686                                                  1/1

Installed:

  mlocate.i686 0:0.22.2-4.el6                                                                    

Complete!

但是

[root@localhost tmp]# locate passwd

locate: can not stat () `/var/lib/mlocate/mlocate.db': 没有那个文件或目录

安装成功了,现在使用 updatedb 命令来创建locate命令依赖的数据库。

[root@localhost tmp]# updatedb

这样就OK了