首页 技术 正文
技术 2022年11月18日
0 收藏 1000 点赞 3,584 浏览 2453 个字

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则是存放文件信息的文件;

上一篇: malloc 实现原理
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,104
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,581
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,428
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,200
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,835
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,918