Linux下,查找根目录下具有SUID/SGID的文件,如何使用find?
阿神
阿神 2017-04-17 15:37:17
0
1
757

描述问题

查找具有SUID or SGID权限的文件
我自己构造的命令是find / -type f -perm u+s,g+s

搜索了一下(https://www.google.co.jp/webh...
好像命令是find directory -user root -perm -4000 find $DIRECTORY -perm /4000

有几点不理解:

  1. 其他权限设置成0, 与我的要求有点不符合吧? (其他权限随意)

  2. 为什么要加一个/?

  3. 记不住SUID的数字, 用其他方式书写,怎么写?

上下文环境

Linux-Server
系统自带find
阿神
阿神

闭关修行中......

全部回复(1)
伊谢尔伦

man find

   -perm mode
          File's  permission  bits  are  exactly mode (octal or symbolic).  Since an exact match is required, if you want to use this form for symbolic modes, you may have to specify a rather complex mode string.  For example `-perm g=w' will
          only match files which have mode 0020 (that is, ones for which group write permission is the only permission set).  It is more likely that you will want to use the `/' or `-' forms, for example `-perm -g=w', which matches  any  file
          with group write permission.  See the EXAMPLES section for some illustrative examples.

   -perm -mode
          All  of  the  permission bits mode are set for the file.  Symbolic modes are accepted in this form, and this is usually the way in which you would want to use them.  You must specify `u', `g' or `o' if you use a symbolic mode.   See
          the EXAMPLES section for some illustrative examples.

   -perm /mode
          Any of the permission bits mode are set for the file.  Symbolic modes are accepted in this form.  You must specify `u', `g' or `o' if you use a symbolic mode.  See the EXAMPLES section for some illustrative examples.  If no  permis‐
          sion bits in mode are set, this test matches any file (the idea here is to be consistent with the behaviour of -perm -000).

所以,确切匹配为: -perm mode,只匹配模式为 mode 的文件,加 / 为 or 匹配, - 为 and 匹配。其他书写方式:-perm -u+s,g+s -perm /u+s,g+s

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板