博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
关于find的-perm
阅读量:4447 次
发布时间:2019-06-07

本文共 2211 字,大约阅读时间需要 7 分钟。

关于find的-perm

参考

总结

有三种用法

  • find -perm -mode
  • find -perm mode
  • find -perm /mode(find -perm +mode已经废弃)

第一种

find -perm -mode

-mode表示完全满足mode权限。

搜索的文件权限可以比mode高

比如mode位644,那么可以搜索到644的,744的,666的,777也行,比644高就行

比如,我要/etc目录下权限至少是755的普通文件,

会发现,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...

查找/etc⽬录下⾄少有⼀类⽤户没有执⾏权限的⽂件

先查找所有用户都有执行权限的,再取反

[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

查找/tmp⽬录下,所有⽤户都有执⾏权限,且其它⽤户有写权限的⽂件

[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

第二种

find -perm mode

这样就表示完全匹配了

我要755的,就给我755,要644的就给我644

比如:我只要/etc/目录下面权限为755的普通文件

会发现,所有搜到的文件权限都是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...

第三种

find -perm /mode

/mode表示部分满足即可

我要755的,那么111的也行,100的也行,但022的不行,因为022(-----w--w-)两个位置不符合要求,不是我要的

例如:查找/tmp目录下面有执行权限的文件,不管什么用户有都行

可以看到,不管是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...

例如:查找/etc目录下面所有用户都没有写权限的文件

取反即可

[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...

例如:查找/etc目录下面s所有用户都没有写权限的文件

[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

你可能感兴趣的文章
python sendmail
查看>>
centOS7下安装GUI图形界面
查看>>
如何为XNA创建输入框(how to Create an XNA Textbox)
查看>>
UWP&WP8.1 基础控件——Grid
查看>>
【JavaScript】 直接下载保存文件
查看>>
006 Cisco switch prewired
查看>>
数据结构和算法概览(一)
查看>>
log4net使用具体解释
查看>>
UVA 11774 - Doom's Day(规律)
查看>>
DWZ使用笔记
查看>>
大屏前段框架的实现 ( 一 )
查看>>
EBS销售订单挑库发放处理程序
查看>>
Android使用Jenkins自动化构建测试打包apk
查看>>
Cheap Tricks: Let's Talk About METADATA TypeLibs
查看>>
电子书下载:Programming Windows Phone 7
查看>>
SpringCloud实战——(1)创建SpringCloud项目
查看>>
selenium-01-2环境搭建
查看>>
在ASP.NET MVC 中获取当前URL、controller、action(转载)
查看>>
char,wchar_t,WCHAR,TCHAR,ACHAR的区别----LPCTSTR
查看>>
A + B Problem II
查看>>