一、find命令
find / -name '文件名'
例如:
[root@localhost ~]# find / -name 'my.cnf'
/etc/my.cnf
二、locate命令
locate xxxx(文件名)
例如:
[root@localhost ~]# locate my.cnf
/etc/my.cnf
/etc/my.cnf.d
注:locate: 未找到命令
1、安装"locate"命令。运行“yum install mlocate”
2、出现提示:Is this ok [y/d/N],都执行y。
3、mlocate安装完成。需更新后台数据库,输入命令:updatedb。
[root@localhost ~]# yum install mlocate
已加载插件:fastestmirrorLoading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
base | 3.6 kB 00:00:00
extras | 3.4 kB 00:00:00
mysql-connectors-community | 2.5 kB 00:00:00
mysql-tools-community | 2.5 kB 00:00:00
mysql56-community | 2.5 kB 00:00:00
updates | 3.4 kB 00:00:00
正在解决依赖关系
--> 正在检查事务
---> 软件包 mlocate.x86_64.0.0.26-8.el7 将被 安装
--> 解决依赖关系完成
依赖关系解决 =================================================================================================================================================================================
Package 架构 版本 源 大小 =================================================================================================================================================================================
正在安装:
mlocate x86_64 0.26-8.el7 base 113 k事务概要 =================================================================================================================================================================================
安装 1 软件包
总下载量:113 k
安装大小:379 k
Is this ok [y/d/N]: y
Downloading packages:
mlocate-0.26-8.el7.x86_64.rpm | 113 kB 00:00:01
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装 : mlocate-0.26-8.el7.x86_64 1/1
验证中 : mlocate-0.26-8.el7.x86_64 1/1
已安装: mlocate.x86_64 0:0.26-8.el7 完毕!
[root@localhost ~]# updatedb