Linux命令之locate命令
1.locate
locate 命令是文件搜索命令,它的搜索速度比 find 命令更快,原因在于它不搜索具体目录,
而是搜索一个数据库,这个数据库包含本地所有文件信息。Linux系统自动创建这个数据库,
并且每天自动更新一次,所以使用 locate 这个命令查不到最新变动过的文件。为了避免这种情况
可以在使用locate之前,先使用 updatedb 命令,手动更新数据库。
命令格式:
locate [文件名]
#Example01 在var目录下添加index.hml
[root@VM_81_181_centos /]# locate index.html
/usr/share/doc/HTML/index.html
/usr/share/doc/cyrus-sasl-lib-2.1.23/index.html
/usr/share/doc/db4-utils-4.7.25/utility/index.html
/usr/share/doc/gamin-0.1.10/index.html
/usr/share/doc/python-babel-0.9.4/doc/index.html
/usr/share/doc/python-babel-0.9.4/doc/api/identifier-index.html
/usr/share/doc/python-babel-0.9.4/doc/api/index.html
/usr/share/doc/python-babel-0.9.4/doc/api/since-index.html
/usr/share/doc/python-iniparse-0.3.1/index.html
/usr/share/doc/python-jinja2-2.2.1/ext/django2jinja/templates/index.html
/usr/share/doc/python-jinja2-2.2.1/html/genindex.html
/usr/share/doc/python-jinja2-2.2.1/html/index.html
/usr/share/doc/python-pygments-1.1.1/docs/build/index.html
/usr/share/doc/rsyslog-5.8.10/index.html
/usr/share/doc/udev-147/writing_udev_rules/index.html
发现并没有搜索到/var/index.html
使用 updatedb 命令:
[root@VM_81_181_centos /]# updatedb
[root@VM_81_181_centos /]# locate index.html
/usr/share/doc/HTML/index.html
/usr/share/doc/cyrus-sasl-lib-2.1.23/index.html
/usr/share/doc/db4-utils-4.7.25/utility/index.html
/usr/share/doc/gamin-0.1.10/index.html
/usr/share/doc/python-babel-0.9.4/doc/index.html
/usr/share/doc/python-babel-0.9.4/doc/api/identifier-index.html
/usr/share/doc/python-babel-0.9.4/doc/api/index.html
/usr/share/doc/python-babel-0.9.4/doc/api/since-index.html
/usr/share/doc/python-iniparse-0.3.1/index.html
/usr/share/doc/python-jinja2-2.2.1/ext/django2jinja/templates/index.html
/usr/share/doc/python-jinja2-2.2.1/html/genindex.html
/usr/share/doc/python-jinja2-2.2.1/html/index.html
/usr/share/doc/python-pygments-1.1.1/docs/build/index.html
/usr/share/doc/rsyslog-5.8.10/index.html
/usr/share/doc/udev-147/writing_udev_rules/index.html
/var/index.html
2.当在某些目录下创建文件,然后更新数据库之后,并不能使用 locate 命令查找到
原因是系统在更新数据库的配置文件中,设置了一些限制,所以,搜索不到,输入以下命令可以看到:
[root@VM_81_181_centos lib]# vi /etc/updatedb.conf PRUNE_BIND_MOUNTS = "yes"
PRUNEFS = "9p afs anon_inodefs auto autofs bdev binfmt_misc cgroup cifs coda configfs cpuset debugfs devpts ecryptfs exofs fuse fusectl gfs gfs2 hugetlbfs inotifyfs iso9660 jffs2 lustre mqueue ncpfs nfs nfs4 nfsd pipefs proc ramfs rootfs rpc_pipefs securityfs selinuxfs sfs sockfs sysfs tmpfs ubifs udf usbfs"
PRUNENAMES = ".git .hg .svn"
PRUNEPATHS = "/afs /media /net /sfs /tmp /udev /var/cache/ccache /var/spool/cups /var/spool/squid /var/tmp"
PRUNE_BIND_MOUNTS = “yes” 表示开启搜索限制,如果为’no’则表示不开启搜索限制;
PRUNEFS = 表示搜索时,不搜索的文件系统;
PRUNENAMES = 表示搜索时,不搜索的文件类型;
PRUNEPATHS = 表示搜索时,不搜索的路径;
不只locate命令遵循搜索限制,whereis与which也遵循
Linux命令之locate命令的更多相关文章
- Linux which/whereis/locate命令详解
which 查看可执行文件的位置,从全局环境变量PATH里面查找对应的路径,默认是找 bash内所规范的目录 whereis 查看文件的位置,配合参数-b,用于程序名的搜索,从linux数据库查找. ...
- 常用linux命令:locate 命令
locate 让使用者可以很快速的搜寻档案系统内是否有指定的档案.其方法是先建立一个包括系统内所有档案名称及路径的数据库,之后当寻找时就只需查询这个数据库,而不必实际深入档案系统之中了.在一般的 di ...
- linux常用命令(16)locate命令
locate 让使用者可以很快速的搜寻档案系统内是否有指定的档案.其方法是先建立一个包括系统内所有档案名称及路径的数据库,之后当寻找时就只需查询这个数据库,而不必实际深入档案系统之中了.在一般的 di ...
- linux里添加locate命令
在linux里使用和find一样的功能 例如 find -name xx 可以yum install mlocate 然后 updatedb 再使用locate xx 来查找xx文件
- Linux 命令中 which、whereis、locate 命令的用法
which 命令 which 命令的作用是,在 PATH 变量指定的路径中搜索可执行文件的所在位置.它一般用来确认系统中是否安装了指定的软件. (1)命令格式 which 可执行文件名称 wherei ...
- Linux使用locate命令定位文件
FIND命令 很多Linux用户喜欢使用find命令来查找文件,例如他们通常喜欢这样做: find / -name 'pattern' 确实find的强大功能不仅仅用来查找文件,它能用来定位更加细节的 ...
- Linux下相关查找文件命令(find locate which whereis type)
以下内容摘自:http://blog.csdn.net/jessica1201/article/details/8139249 标注的内容为自己的补充: 我们经常需要在系统中查找一个文件,那么在lin ...
- Linux的五个查找命令find,locate,whereis,which,type
Linux的五个查找命令 1. find 最常见且最强大的命令,可以查找任何文件. 格式 $ find 指定目录 指定条件 指定动作 指定目录: 所要搜索的目录及其子目录,默认当前目录 ...
- linux locate命令
1.命令简介 locate(locate) 命令用来查找文件或目录. locate命令要比find -name快得多,原因在于它不搜索具体目录,而是搜索一个数据库/var/lib/ml ...
随机推荐
- 【转载】selenium与自动化测试成神之路
Python selenium —— selenium与自动化测试成神之路 置顶 2016年09月17日 00:33:04 阅读数:43886 Python selenium —— selenium与 ...
- flask模板应用-空白控制
模板应用实践 空白控制 在实际输出的HTML文件中,模板中的jinja2语句.表达式和注释会保留移除后的空行. 例如下面的代码: {% set user.age = 23 %} {% if urer. ...
- 区块链3.0 ada Cardano卡尔达诺如何获得一致好评?
区块链3.0 ada Cardano卡尔达诺如何获得一致好评? EOS 的直接竞争对手是以太坊.文章介绍的卡尔达诺(Cardano)的目标就更加远大了,他要同时锁定比特币和以太坊.但大家去网上搜索卡尔 ...
- DOM jquery
DOM 文档对象模型(Document Object Model)是一种用于HTML和XML文档的编程接口.它给文档提供了一种结构化的表示方法,可以改变文档的内容和呈现方式.我们最为关心的是,DOM ...
- Codeforces 841B - Godsend
题目链接:http://codeforces.com/problemset/problem/841/B Leha somehow found an array consisting of n inte ...
- C++ 开源库列表
https://zh.cppreference.com/w/cpp/links/libs
- MyEclipse项目的jquery.js发生[Multiple markers at this line - Missing semicolon]的解决方案
问题描述: 导入jquery库后,发现提示错误信息:Multiple markers at this line - Missing semicolon,如下截图所示: 解决方案: 选中该jquery. ...
- Kattis之旅——Fractional Lotion
Freddy practices various kinds of alternative medicine, such as homeopathy. This practice is based o ...
- How to click on a point on an HTML5 canvas in Python selenium webdriver
https://stackoverflow.com/questions/29624949/how-to-click-on-a-point-on-an-html5-canvas-in-python-se ...
- mysqldump进行复制数据导出导入时的问题
在执行数据导入到从库时,若使用mysqldump命令进行数据导出,应当一次性将需要同步的库导出. mysqldump -uroot -p --single-transaction --database ...