Linux/Centos 在用搜索命令locate时 command not found 问题

来源:互联网 发布:linux 下载php源码 编辑:程序博客网 时间:2024/06/06 18:43

在用locate查找命令找文件时提示如下:

-bash: locate: command not found

所以就想着是不是locate要yum来安装才可以呢,于是:

[root@localhost ~]# yum install locate

结果是No package locate available

接着就updatedb试试,提示:

-bash:updatedb:command not found

网上查了一下要先安装mlocate相应的包才可以,以前是slocate现在已被mlocate取代。

故:[root@localhost ~]# yum -y install mlocate
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package mlocate.x86_64 0:0.22.2-6.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===========================================================================================================================================================
 Package                             Arch                               Version                                     Repository                        Size
===========================================================================================================================================================
Installing:
 mlocate                             x86_64                             0.22.2-6.el6                                base                              86 k

Transaction Summary
===========================================================================================================================================================
Install       1 Package(s)

Total download size: 86 k
Installed size: 279 k
Downloading Packages:
mlocate-0.22.2-6.el6.x86_64.rpm                                                                                                     |  86 kB     00:00     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : mlocate-0.22.2-6.el6.x86_64                                                                                                             1/1
  Verifying  : mlocate-0.22.2-6.el6.x86_64                                                                                                             1/1

Installed:
  mlocate.x86_64 0:0.22.2-6.el6                                                                                                                            

Complete!

安装成功!执行locate passwd来搜索文件还是有报错

[root@localhost ~]# locate passwd
locate: can not stat () `/var/lib/mlocate/mlocate.db': No such file or directory

还要使用updatedb命令来创建locate命令依赖的数据库

[root@localhost ~]# updatedb

下面就可以使用locate命令了。


阅读全文
0 0