博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
linux locate
阅读量:4944 次
发布时间:2019-06-11

本文共 2225 字,大约阅读时间需要 7 分钟。

locate命令查找文件比find速度快很多,locate是在linux下实现快速查找文件的工具.相应的windows下有everything功能也很强大.

[root@wuzhigang lib]# updatedb

-bash: updatedb: command not found

原来是服务器中没有安装mlocate

[root@wuzhigang lib]# yum install mlocate

Loaded plugins: fastestmirror, refresh-packagekit
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Repository contrib is listed more than once in the configuration
Loading mirror speeds from cached hostfile
 * base: mirrors.163.com
 * extras: ftp.sjtu.edu.cn
 * nux-dextop: li.nux.ro
 * updates: mirrors.163.com
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package mlocate.x86_64 0:0.22.2-4.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=======================================================================================================================================
 Package                        Arch                          Version                                Repository                   Size
=======================================================================================================================================
Installing:
 mlocate                        x86_64                        0.22.2-4.el6                           base                         86 k
Transaction Summary
=======================================================================================================================================
Install       1 Package(s)
Total download size: 86 k
Installed size: 279 k
Is this ok [y/N]: y
Downloading Packages:
mlocate-0.22.2-4.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-4.el6.x86_64                                                                                         1/1
  Verifying  : mlocate-0.22.2-4.el6.x86_64                                                                                         1/1
Installed:
  mlocate.x86_64 0:0.22.2-4.el6                                                                                                        
Complete!

 

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

[root@wuzhigang lib]# updatedb
[root@wuzhigang lib]# locate passwd

 

整个locate工作其实是由四部分组成的:

  • /usr/bin/updatedb
  • /usr/bin/locate or mlocate
  • /etc/updatedb.conf
  • /var/lib/mlocate/mlocate.db

updatedb主要用来更新数据库,这个工作是通过crontab自动完成的. 

mlocate/locate是作来完成查询功能的程序;
updatedb.conf是配置要查询哪些目录, 哪些文件;
mlocate.db则是存放文件信息的文件;

转载于:https://www.cnblogs.com/agang-php/p/4099440.html

你可能感兴趣的文章
配置交换空间与文件系统的备份
查看>>
自定义类型使用泛型
查看>>
【洛谷】【堆+贪心】P1484 种树
查看>>
scala中的特殊字符
查看>>
日期控件工具
查看>>
自然语言处理(2)之文本资料库
查看>>
Prim和Kruskal算法
查看>>
BZOJ1123 [POI2008]BLO
查看>>
PHP获取随机字符串的两种方法
查看>>
清空StringBuilder的三种方法及效率
查看>>
StringUtils一些常用方法
查看>>
TextView 在java中使用Html设置字体大小颜色
查看>>
python安装及配置
查看>>
Android学习二:Http操作
查看>>
探秘手淘高可用平台(三)——热修复和开发流程
查看>>
使用vue-cli3搭建项目详细步骤
查看>>
VC2008中使用GDI+(转)
查看>>
Keepalived原理与实战精讲
查看>>
多线程设计模式(二):Future模式
查看>>
转 Hystrix超时实现机制
查看>>