whereis、locate 查找与命令对应的文件
来源:互联网 发布:云服务百度 计算 编辑:程序博客网 时间:2024/05/17 08:15
命令解释
在Linux下面,有很多优秀的查找命令。一般情况下我们并不会去使用find
,因为速度很慢。更多的时候使用whereis
和locate
这两个命令,因为它们两个是利用数据库去查找数据,所以相当快速,如果真找不到了,才会使用find
来查询。
whereis 寻找特定文件
命令说明
[root@localhost ~]# whereis [-bmsu] 文件或目录名参数:-b : 只查找二进制格式文件。-m : 只查找说明文件 manual 路径下的文件。-s : 只查找 source 源文件。-u : 查找不在上述三种选项之中的其他特殊文件。
命令举例
例子一:请使用不同身份找出 ifconfig 这个文件名[root@localhost ~]# whereis ifconfigifconfig: /sbin/ifconfig /usr/share/man/man8/ifconfig.8.gz[wenjie@localhost root]$ su - wenjie[wenjie@localhost ~]$ whereis ifconfigifconfig: /sbin/ifconfig /usr/share/man/man8/ifconfig.8.gz# 当我们使用 shich 的时候,是找不到这个文件的,而使用 whereis 却可以顺利找到。# 说明系统真有 ifconfig 这个“文件”,至饿时用户的 PATH 并没有加入 /sbin。例子二:只查找出跟 passwd 有关的“说明文件”文件名[root@localhost wenjie]# whereis -m passwdpasswd: /usr/share/man/man5/passwd.5.gz /usr/share/man/man1/passwd.1.gz
locate 根据文件部分名称去查找文件
命令说明
[root@localhost ~]# locate [-ir] keyword参数:-i : 忽略大小写的差异。-r : 后面可以接正则表达式的显示方式。
命令举例
例子一:找出系统中所有与 passwd 相关的文件名[root@localhost ~]# locate ifconfig/sbin/ifconfig/usr/share/man/de/man8/ifconfig.8.gz/usr/share/man/fr/man8/ifconfig.8.gz/usr/share/man/man8/ifconfig.8.gz/usr/share/man/pt/man8/ifconfig.8.gz
更新查找数据库
因为whereis
和locate
这两个查找命令是根据数据库中的数据去查找的,所以如果数据库中数据没有及时更新的话,我们有可能会查找出已经删除、或者查找不出刚刚新建的文件。数据库默认是一天更新一次,所以当你做新建或者删除操作的时候,你会发现出问题。
如果我们创建或删除一个文件之后,想及时更新,该怎么办呢?
可以使用updatedb
命令,这个命令就会及时将数据库更新。
updatedb 及时更新数据库
- 根据 /etc/updatedb.conf 的设置去查找系统硬盘内的文件名,并更新 /var/lib/mlocate 内的数据库文件。
0 0
- whereis、locate 查找与命令对应的文件
- 文件查找命令find,locate,whereis,which
- 文件查找命令 whereis locate find
- 文件查找命令-which,whereis,locate,find
- Linxu命令与文件的搜索 - which, whereis, locate, find
- 命令与文件的查询 which whereis locate find
- linux中Find、whereis、locate、which查找文件命令总结
- linux中Find、whereis、locate、which查找文件命令总结
- 查找文件命令---find, locate, whereis, which, type
- linux中Find、whereis、locate、which查找文件命令详解
- Linux下which、whereis、locate、find 命令查找文件
- Linux下which、whereis、locate、find 命令查找文件
- Linux下which、whereis、locate、find 命令查找文件
- Linux下which、whereis、locate、find 命令查找文件
- Linux文件查找命令详解-which whereis find locate
- linux 下查找文件或者内容命令whereis,locate ,find
- Linux基本功——五个查找文件的命令find,locate,whereis,which,type
- Linux的五个文件查找命令:find,locate,whereis,which,type
- OTP EEPROM介绍
- Nginx + CGI/FastCGI + C/Cpp
- Android 面试题整理
- Google官网蓝牙通信模块BluetoothChatService类分析与使用
- 树、森林和二叉树的转换
- whereis、locate 查找与命令对应的文件
- 使用IRP进行文件操作
- iOS学习项目(24-layer)
- Cocos2dx 场景类-Scene
- NETIF_STATUS_CALLBACK何时会被调用
- 五种方式显示圆形图片
- UISearchController搜索框禁止向上移动
- json 格式解析 及使用
- Microsoft CRM 2016 IFD配置