首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往
您找到你想要的搜索结果了吗?
是的
没有找到

Linux下which、whereis、locate、find 区别

我们经常在linux要查找某个文件或命令,但不知道放在哪里了,可以使用下面的一些命令来搜索。 which      查看可执行文件的位置  whereis    查看文件的位置  locate     配合数据库查看文件位置  find       实际搜寻硬盘查询文件名称  1、which  语法: which 可执行文件名称  例如:  [root@redhat ~]# which passwd  /usr/bin/passwd  which是通过 PATH 环境变量到该路径内查找可执行文件,所以基本的功能是寻找可执行文件  2、whereis  语法: whereis [-bmsu] 文件或者目录名称  参数说明:  -b : 只找二进制文件  -m: 只找在说明文件manual路径下的文件  -s : 只找source源文件  -u : 没有说明文档的文件  例如:  [root@redhat ~]# whereis passwd  passwd: /usr/bin/passwd /etc/passwd /usr/bin/X11/passwd /usr/share/man/man5/passwd.5.gz /usr/share/man/man1/passwd.1.gz /usr/share/man/man1/passwd.1ssl.gz 将和passwd文件相关的文件都查找出来  [root@redhat ~]# whereis -b passwd passwd: /usr/bin/passwd /etc/passwd /usr/bin/X11/passwd  只将二进制文件 查找出来  和find相比,whereis查找的速度非常快,这是因为linux系统会将系统内的所有文件都记录在一个数据库文件中,当使用whereis和下面即将介绍的locate时,会从数据库中查找数据,而不是像find命令那样,通过遍历硬盘来查找,效率自然会很高。  但是该数据库文件并不是实时更新,默认情况下时一星期更新一次,因此,我们在用whereis和locate 查找文件时,有时会找到已经被删除的数据,或者刚刚建立文件,却无法查找到,原因就是因为数据库文件没有被更新。  3、 locate  语法: locate 文件或者目录名称  例 如:  [root@redhat ~]# locate passwd  /etc/passwd /etc/passwd- /etc/cron.daily/passwd /etc/init/passwd.conf /etc/init.d/passwd /etc/pam.d/chpasswd /etc/pam.d/passwd /etc/security/opasswd …………

04

ubuntu find方法

通用格式:find pathname -options [-print -exec -ok] 例子: find / -name filename 再根目录里面搜索文件名为filename的文件 find /etc -name *s*在目录里面搜索带有s的文件 find /etc -name *S 在目录里面搜索以s结尾的文件 find /etc -name s*在目录里面搜索以s开头的文件 find / -amin -10在系统中搜索最后10分钟访问的文件 find / -atime -2查找在系统中最后48小时访问的文件 find / -empty 查找在系统中为空的文件或者是文件夹 find / -group groupname 查找在系统中属于groupname的文件 find / -mmin -5查找在系统中最后5分钟修改过的文件 find / -mtime -1查找在系统中最后24小时修改过的文件 find /-nouser查找在系统中属于费用户的文件 find / -user username 查找在系统中属于username的文件 find / -ctime -1查找在系统中最后24小时被改变状态的文件 find / -fstype type查找在系统中文件类型为?的文件 find / -user user1name -or -user user2name查找在系统中属于user1name或着属于user2name的文件 find / -user user1name -and -user2name在系统中查找既属于user1name又属于user2name用户的文件.

03
领券