Linux下,查找根目录下具有SUID/SGID的文件,如何使用find?

查看:165
本文介绍了Linux下,查找根目录下具有SUID/SGID的文件,如何使用find?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问 题

描述问题

查找具有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

解决方案

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

这篇关于Linux下,查找根目录下具有SUID/SGID的文件,如何使用find?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆