find命令基本用法详解

find命令是用来查询指定文件,用法如下

1.-name 通过文件名来查找

[root@localhost ~]# find /etc/ -name passwd
/etc/passwd
/etc/pam.d/passwd
[root@localhost mnt]# find /etc/ -name *.conf

2.-group表示文件的所有组,-user表示文件所有人

搭建实验环境

实验开始

[root@localhost ~]# find /mnt -user student 
/mnt/file1
/mnt/file3

 

[root@localhost ~]# find /mnt -group westos
/mnt/file2
/mnt/file3

[root@localhost ~]# find /mnt -user root -group westos
/mnt/file2
-a表示并且

[root@localhost ~]# find /mnt -user root -a -group westos
/mnt/file2
-o表示或者

 

[root@localhost ~]# find /mnt -not -user student
-not表示非;即反向选择

 

3.文件深度查询

-maxdepth                       ##最大深度
-mindepth                       ##最小深度
[root@localhost ~]# find /etc/ -maxdepth 1 -name passwd
/etc/passwd
[root@localhost ~]# find /etc/ -maxdepth 2 -name passwd
/etc/passwd
/etc/pam.d/passwd
[root@localhost ~]# find /etc/ -mindepth 1 -maxdepth 2 -name *.conf

4.文件大小查询

建立实验环境

5.指定文件类型查询

-type   	##根据指定类型查找(-,d,l,s,f,b)

6.指定文件创建时间查询

find    -cmin 10	##查找10min结点上修改过的文件
find	-cmin -10	##查找10min以内修改过的文件
find	-cmin +10	##修改超过10min的文件
find    -ctime +|-|10	##不指定默认为查找时间为:天

7.权限查询法

find	-perm 644	##查找指定权限(004)的文件	
find	-perm -644	## "-"表示“与”,ug位无要求且o为有r权限
find	-perm /644	## '/'表示'或',只要o位有r权限即可

搭建实验环境

 

实验

-exec commd {} \        {}表示find的输出
			-exec 后加想要执行的动作
			必须是空格后加\;\表示对分号进行转义

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值