cento命令之which、whereis、locate、find
【which】
查看可执行文件的位置
语法:
[root@localhost ~]# which 可执行文件名称
例如:
[root@localhost ~]# which passwd
/usr/bin/passwd
which是通过PATH环境变量到该路径内查找可执行文件,所以基本的功能是寻找可执行文件。
【whereis】
语法:
[root@localhost ~]# whereis [-bmsu] 文件或者目录名称
参数说 明:
-b : 只找二进制文件
-m: 只找在说明文件manual路径下的文件
-s : 只找source源文件
-u : 没有说明文档的文件
例如:
[root@localhost ~]# whereis passwd
passwd: /usr/bin/passwd /etc/passwd /usr/share/man/man1/passwd.1.gz /usr/share/man/man5/passwd.5.gz
将和passwd文件相关的文件都查找出来。
[root@localhost ~]# whereis -b passwd
passwd: /usr/bin/passwd /etc/passwd
只将二进制文件查找出来。
和find相比,whereis查找的速度非常快,这是因为linux系统会将 系统内的所有文件都记录在一个数据库文件中,当使用whereis和下面即将介绍的locate时,会从数据库中查找数据,而不是像find命令那样,通 过遍历硬盘来查找,效率自然会很高。
但是该数据库文件并不是实时更新,默认情况下时一星期更新一次,因此,我们在用whereis和locate 查找文件时,有时会找到已经被删除的数据,或者刚刚建立文件,却无法查找到,原因就是因为数据库文件没有被更新。
【locate】
配合数据库查看文件位置。
语法:
[root@localhost ~]# locate 文件或者目录名称
例 如:
[root@localhost ~]# locate passwd
/lib/security/pam_unix_passwd.so
/lib/security/pam_passwdqc.so
/usr/bin/vncpasswd
/usr/bin/userpasswd
/usr/bin/yppasswd
…………
【find】
实际搜寻硬盘查询文件名称。
语法:
[root@localhost ~]# 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@localhost ~]# 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@localhost ~]# 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
当我们用whereis和locate无法查找到我们需要的文件时,可以使用find,但是find是在硬盘上遍历查找,因此非常消耗硬盘的资源,而且效率也非常低。
locate 是在数据库里查找,数据库大至每天更新一次。
whereis 可以找到可执行命令和man page。
find 就是根据条件查找文件。
which 可以找到可执行文件和别名(alias) 。
cento命令之which、whereis、locate、find的更多相关文章
- centos 特殊权限 各种搜索命令 lsattr ,chattr,suid,sgid,sbit,file,type是否是内置命令,stat文件属性 ,whereis,locate,find,ln 内部命令和外部命令 第五节课
centos 特殊权限 各种搜索命令 lsattr ,chattr,suid,sgid,sbit,file,type是否是内置命令,stat文件属性 ,whereis,locate,find,ln ...
- Linux 查找文件命令 find whereis locate
Linux 有三个查找文件的命令:find, whereis, locate 其中find 不常用,whereis与locate经常使用,因为find命令速度较慢,因为whereis与locate是利 ...
- linux的查找命令 find whereis locate
Linux 有三个查找文件的命令:find, whereis, locate 其中find 不常用,whereis与locate经常使用,因为find命令速度较慢,因为whereis与locate是利 ...
- linux中的一些基础命令的使用(which,whereis,locate,find,alias,file,ls,cat,echo,tar,bzip2,gzip,history,mv,cp,rm)
which whereis locate find alias file ls cat echotar bzip2 gzip history mv cp rm -------------------- ...
- Linux which/whereis/locate命令详解
which 查看可执行文件的位置,从全局环境变量PATH里面查找对应的路径,默认是找 bash内所规范的目录 whereis 查看文件的位置,配合参数-b,用于程序名的搜索,从linux数据库查找. ...
- Linux指令--which,whereis,locate,find
原文出处:http://www.cnblogs.com/peida/archive/2012/12/05/2803591.html.感谢作者无私分享 which 我们经常在linux要查找某个文件,但 ...
- linux每日命令(18):whereis命令
whereis命令用于查找文件. 该指令会在特定目录中查找符合条件的文件.这些文件应属于原始代码.二进制文件,或是帮助文件. 该指令只能用于查找二进制文件.源代码文件和man手册页,一般文件的定位需使 ...
- linux文件名称查找which,whereis,locate
1. 文件名称查找 使用find查询时.因为磁盘查询.所以速度较慢. 所以linux下查询更常使用which, whereis, locate来查询,因为是利用数据库查询.所以速度非常快. 2. wh ...
- Linux-(which,whereis,locate,find)
我们经常在linux要查找某个文件,但不知道放在哪里了,可以使用下面的一些命令来搜索: which 查看可执行文件的位置. whereis 查看文件的位置. locate 配合数据库查看文件位置 ...
- linux 文件查找,which,whereis,locate,find
linux 文件查找,which,whereis,locate,find 一:which 主要用于查找可执行命令的所在位置: 如图,查找命令 ls的目录: 二:whereis 主要用于查找命令的帮助文 ...
随机推荐
- ES6:string.raw浅析
当前正学习ES6 ,遇到string.raw费心思,现将试验后的结果整理如下: 网上得来的试验: 语法 String.raw`templateStr`; String.raw(obj, ...subs ...
- 从一个LocalDateTime引发的疑问
一 公司有同事部署出错,然后查日志,找时间,从k8s得到的时间是 2017-06-16T09:38:48.580 +0000,然后他就纳闷了,因为他根本不会在9点部署好吧,而且9点大多数程序员都没开 ...
- 字符串和byte数组的相互转化
关于byte[]数组转十六进制字符串: public static String getHexString(byte[] b) throws Exception { String result = & ...
- css3动画:animation
例: -webkit-animation: myfirst 5s linear 2s infinite alternate; animation: myfirst 5s linear 2s infin ...
- 解决ueditor jquery javascript 取值问题
代码如下: var content = UE.getEditor('myEditor').getContent(); myEditor是ueditor 的名称name. 代码如下: <t ...
- 微信小程序中的target和currentTarget区别
最近在学习微信小程序相关知识,其中提到了两个属性target和currentTarget,其中target是指向触发事件的元素(常见于事件委托中),而currentTarget是指向捕获事件的元素(即 ...
- Docker搭建
环境基于CentOS64位,内核最好3.10. 1.下载安装 docker dockersudo yum install docker-io (假如内核版本太低的话,会在下载安装Docker ...
- LR脚本录制方式说明
1.LR脚本录制方式说明1)HTML-based script基于HTML的脚本从内存中读取并下载资源,较少的关联处理,可以加入图片检查,回放时需要解析返回的信息a-基于用户行为的方式 web_lin ...
- 全站变灰的CSS代码-适合特殊时刻哀悼
将下面CSS代码应用到HTML标签或者是BODY标签 filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.o ...
- Codeforces Round #411 div2
A. Fake NP 题意:询问一个区间[L,R]出现次数最多的正整数因子(>1). 一个区间内一个因子P出现次数大概为[R/P]-[(L-1)/P],约等于(R-L+1)/P,P取2时最优.注 ...