find命令 参数

记一下我遇到过的:
!表示否定
-a 表示并且
-o  或者
 
perm注意权限模式,有无 -,单表含义不同,有-是表示属主、组、其他组权限对应(即某位为0时,表示不指定要匹配的权限,而不是没有权限), 没有-时表示所有权限综合
////有解释说-表示都匹配,如-0005表示0555;需要验证一下真假
[root@localhost ~]# chmod 005 /etc/ppp
[root@localhost ~]# ls -ld /etc/ppp
d------r-x. 3 root root 4096 1月  25 23:13 /etc/ppp
[root@localhost ~]# find /etc/ppp  \( -perm -005 \) -print
/etc/ppp
/etc/ppp/ip-down
/etc/ppp/ip-down.ipv6to4
/etc/ppp/ip-up
/etc/ppp/ip-up.ipv6to4
/etc/ppp/ipv6-down
/etc/ppp/ipv6-up
/etc/ppp/peers

[root@localhost ~]# chmod 005 /etc/ppp
[root@localhost ~]# ls -ld /etc/ppp
d------r-x. 3 root root 4096 1月  25 23:13 /etc/ppp
[root@localhost ~]# find /etc/ppp  \( -perm 111 \) -print
[root@localhost ~]# find /etc/ppp  \( -perm -001 \) -print
/etc/ppp
/etc/ppp/ip-down
/etc/ppp/ip-down.ipv6to4
/etc/ppp/ip-up
/etc/ppp/ip-up.ipv6to4
/etc/ppp/ipv6-down
/etc/ppp/ipv6-up
/etc/ppp/peers

[root@localhost ~]#
//////////////////
如上,我改目录权限为005,使用-perm -005 输出了该目录,说明匹配的不是555;
使用-perm 111时无输出,使用-perm -001时,输出目录
说明-匹配的是包含有该位指定权限的
而不是都匹配;
没有-时,表示要匹配完全相同的权限,证明如下:
[root@localhost ~]# ls -la /etc/ppp
总用量 64
d--x--xr-x.   3 root root 4096 1月  25 23:13 .
drwxr-xr-x. 134 root root 8192 1月  27 00:35 ..
-rw-------.   1 root root   78 8月  10 03:03 chap-secrets
-rw-------.   1 root root  349 8月  10 03:03 eaptls-client
-rw-------.   1 root root  405 8月  10 03:03 eaptls-server
-rwxr-xr-x.   1 root root  386 4月   2 2014 ip-down
-rwxr-xr-x.   1 root root 3214 4月   2 2014 ip-down.ipv6to4
-rwxr-xr-x.   1 root root  430 4月   2 2014 ip-up
-rwxr-xr-x.   1 root root 6426 4月   2 2014 ip-up.ipv6to4
-rwxr-xr-x.   1 root root 1687 4月   2 2014 ipv6-down
-rwxr-xr-x.   1 root root 3182 4月   2 2014 ipv6-up
-rw-r--r--.   1 root root    5 8月  10 03:03 options
-rw-------.   1 root root   77 8月  10 03:03 pap-secrets
drwxr-xr-x.   2 root root   19 1月  25 23:17 peers

[root@localhost ~]# find /etc/ppp  \( -perm 115 \) -print
/etc/ppp
[root@localhost ~]# find /etc/ppp  \( -perm 111 \) -print
[root@localhost ~]#
/////////////////
 
 
 
 
比如:
# find PART -xdev -type d \( -perm -0002 -a ! -perm -1000 \) -print
 
找出其他用户可写且未设置stricky的目录
 
 
 
 

-xdev选项,那么仅仅会在在当前文件系统中搜索,下面是在xdev的man page上面找到的一段-xdev的定义:

  • -xdev Don’t descend directories on other filesystems.

会在/目录及其子目录下搜索当前文件系统(也就是/挂载的文件系统

http://blog.sae.sina.com.cn/archives/950
posted @ 2017-06-21 15:03  指尖的乐律  阅读(351)  评论(0编辑  收藏  举报