-mode表示完全满足mode权限。
搜索的文件权限可以比mode高
比如mode位644,那么可以搜索到644的,744的,666的,777也行,比644高就行
会发现,755的也满足要求
[root@centos7 ~]# find /etc/ -perm -011 -type f -print0 | xargs -0 ls -ldh
-rwxr-xr-x. 1 root root 1.3K Oct 31 2018 /etc/auto.net
-rwxr-xr-x. 1 root root 687 Oct 31 2018 /etc/auto.smb
...
先查找所有用户都有执行权限的,再取反
[root@centos7 tmp]# find /etc/ \( -not -perm -111 \) -type f -print0 | xargs -0 ls -ldh | more
-rw-r--r--. 1 root root 850 Nov 14 2018 /etc/abrt/abrt-action-save-package-data.conf
-rw-r--r--. 1 root root 2.1K Nov 14 2018 /etc/abrt/abrt.conf
[root@centos7 tmp]# find /tmp -perm -113 -type f -print0 | xargs -0 ls -ldh
-rwx--x-wx 1 root root 0 Aug 3 11:18 /tmp/111.txt
这样就表示完全匹配了
我要755的,就给我755,要644的就给我644
会发现,所有搜到的文件权限都是755
[root@centos7 ~]# find /etc/ -perm 755 -type f -print0 | xargs -0 ls -ldh
-rwxr-xr-x. 1 root root 1.3K Oct 31 2018 /etc/auto.net
-rwxr-xr-x. 1 root root 687 Oct 31 2018 /etc/auto.smb
...
/mode表示部分满足即可
我要755的,那么111的也行,100的也行,但022的不行,因为022(-----w--w-)两个位置不符合要求,不是我要的
可以看到,不管是001的,755的,都找到了
[root@centos7 tmp]# find /tmp/ -perm /111 -type f -print0 | xargs -0 ls -ldh
-rwxr--r-- 1 root root 0 Aug 3 11:06 /tmp/10.txt
-rwxr-xr-x 1 root root 0 Aug 3 11:07 /tmp/6.txt
---------x 1 root root 0 Aug 3 11:07 /tmp/8.txt
...
取反即可
[root@centos7 tmp]# find /etc/ \( -not -perm /111 \) -type f -print0 | xargs -0 ls -ldh | more
-rw-r--r--. 1 root root 850 Nov 14 2018 /etc/abrt/abrt-action-save-package-data.conf
-rw-r--r--. 1 root root 2.1K Nov 14 2018 /etc/abrt/abrt.conf
...
[root@centos7 tmp]# find /etc/ \( -not -perm /222 \) -type f -print0 | xargs -0 ls -ldh | more
-r--r--r--. 1 root root 460 Apr 11 2018 /etc/dbus-1/system.d/cups.conf
---------- 1 root root 819 Aug 2 15:04 /etc/gshadow
----------. 1 root root 828 Aug 2 15:04 /etc/gshadow-
...
原文:https://www.cnblogs.com/uscWIFI/p/11294204.html