Linux下4个查找命令which、whereis、locate、find的区别
来源:互联网 发布:win10 手写笔绘图软件 编辑:程序博客网 时间:2024/06/11 11:50
引言:我们经常在linux下要查找某个文件、某个目录或某个命令,但不知道放在哪里了,可以使用下面的一些命令来搜索
which 只能查可执行文件的位置 ,在PATH变量里面寻找
whereis 只能查二进制文件(含可执行文件)、说明文档,源文件或目录名称等,从linux文件数据库(/var/lib/slocate/slocate.db 或 /var/lib/mlocate/mlocate.db)寻找,所以有可能找到刚刚删除,或者没有发现新建的文件
locate 配合数据库查看文件或者目录位置,数据库大至每天更新一次,文件名是部分匹配
find 实际搜寻硬盘查询文件名称
语法: which 可执行文件名称
例如:
[root@redhat ~]# which ls
/bin/ls
which是通过 PATH 环境变量到该路径内查找可执行文件,所以基本的功能是寻找可执行文件
2、whereis
语法: whereis [-bmsu] 文件或者目录名称
参数说明:
-b :只找二进制文件
-m: 只找在说明文件manual路径下的文件 如:/usr/share/man/man1/ls.1.gz
-s :只找source源文件
-u :没有说明文档的文件
例如:
[root@redhat ~]# whereis ls
ls: bin/ls /usr/share/man/man1/ls.1.gz
将和ls文件相关的文件都查找出来
[root@redhat ~]# whereis -b ls
ls: bin/ls
只将二进制文件 查找出来
3、 locate
语法: locate 文件或者目录名称
例 如:
[root@redhat ~]# locate ls
/etc/ls
/etc/ls
/etc/cron.daily/ls
…………
4、 find
语法: find 路径 参数
参数说明:
时间查找参数:
-atime n :将n*24小时内存取过的的文件列出来
-ctime n :将n*24小时内改变、新增的文件或者目录列出来
-mtime n :将n*24小时内修改过的文件或者目录列出来
-newer file :把比file还要新的文件列出来
名称查找参数:
-gid n :寻找群组ID为n的文件
-group name :寻找群组名称为name的文件
-uid n :寻找拥有者ID为n的文件
-user name :寻找用户者名称为name的文件
-name file :寻找文件名为file的文件(可以使用通配符)
例如:
[root@redhat ~]# find / -name zgz
/home/zgz
/home/zgz/zgz
/home/weblogic/bea/user_projects/domains/zgz
/home/oracle/product/10g/cfgtoollogs/dbca/zgz
/home/oracle/product/10g/cfgtoollogs/emca/zgz
/home/oracle/oradata/zgz
[root@redhat ~]# find / -name '*zgz*'
/home/zgz
/home/zgz/zgz1
/home/zgz/zgzdirzgz
/home/zgz/zgz
/home/zgz/zgzdir
/home/weblogic/bea/user_projects/domains/zgz
/home/weblogic/bea/user_projects/domains/zgz/zgz.log00006
/home/weblogic/bea/user_projects/domains/zgz/zgz.log00002
/home/weblogic/bea/user_projects/domains/zgz/zgz.log00004
/home/weblogic/bea/user_projects/domains/zgz/zgz.log
/home/weblogic/bea/user_projects/domains/zgz/zgz.log00008
/home/weblogic/bea/user_projects/domains/zgz/zgz.log00005
- Linux下4个查找命令which、whereis、locate、find的区别
- Linux下4个查找命令which、whereis、locate、find的总结
- Linux的查找命令find,which,whereis,locate区别
- linux下which、whereis、locate、find 命令的区别
- linux下which、whereis、locate、find 命令的区别
- linux下which、whereis、locate、find 命令的区别
- linux下which、whereis、locate、find 命令的区别
- linux下which、whereis、locate、find 命令的区别
- linux下which、whereis、locate、find 命令的区别
- linux下which、whereis、locate、find 命令的区别
- linux下which、whereis、locate、find 命令的区别
- Linux下which、whereis、locate、find 命令的区别
- Linux下which、whereis、locate、find 命令的区别
- linux下which、whereis、locate、find 命令的区别
- linux下which、whereis、locate、find 命令的区别
- Linux下which、whereis、locate、find 命令的区别
- Linux下which、whereis、locate、find 命令的区别
- linux下which、whereis、locate、find 命令的区别
- Gartner发布2017年数据管理技术成熟度曲线
- Android性能优化
- VS2015导入ffmpeg库注意事项
- Lis模板
- Android 5.X的新特性及Material Design
- Linux下4个查找命令which、whereis、locate、find的区别
- android屏幕高度、状态栏高度、titlebar高度详解
- Centos6.6下升级Python
- (二十)Java设计模式之命令模式
- Property 'id' not found on type java.lang.String报错
- Android 5.X的新特性实例
- win7&win10清理垃圾代码
- Spring Cloud构建微服务架构:服务网关(基础)【Dalston版】
- 图像处理的方法列举(普通处理、灰度变换、图像锐化)