LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 927|回复: 5

find -perm + -

[复制链接]
发表于 2005-6-20 21:59:10 | 显示全部楼层 |阅读模式
看了說明也不太了解...

?例呢/
发表于 2005-6-22 06:11:22 | 显示全部楼层
下面的命令查找设置了setuid或setgid位的所有文件:
#find / -perm +6000 -type f -exec ls -ld {} \; > setuid.txt &
下面的命令查找设置了同时拥有setuid和setgid位的所有文件(不过在实际的系统中应该几乎没有这样的文件,你可以自己创建几个符合这个条件的文件,测试一下就知道了):
#find / -perm -6000 -type f -exec ls -ld {} \; > setugid.txt &
回复 支持 反对

使用道具 举报

发表于 2005-6-22 10:32:43 | 显示全部楼层
问一下版主,命令行中的{}是做什么的?
我把它去掉以后,执行结果就不一样了,能说明一下其意思吗?
回复 支持 反对

使用道具 举报

发表于 2005-6-22 14:02:23 | 显示全部楼层
Post by xfmaple
问一下版主,命令行中的{}是做什么的?
我把它去掉以后,执行结果就不一样了,能说明一下其意思吗?

要学会看man手册

  1. -exec command {} \;
  2.               Execute  command;  true  if 0 status is returned.  All following
  3.               arguments to find are taken to be arguments to the command until
  4.               an  argument  consisting of `;' is encountered.  The string `{}'
  5.               is replaced by the current file name being processed  everywhere
  6.               it occurs in the arguments to the command, not just in arguments
  7.               where it is alone, as in some versions of find.  Both  of  these
  8.               constructions might need to be escaped (with a `\') or quoted to
  9.               protect them from expansion by the shell.  See the EXAMPLES sec-
  10.               tion  for examples of the use of the `-exec' option.  The speci-
  11.               fied command is run once for each matched file.  The command  is
  12.               executed  in  the  starting  directory.    There are unavoidable
  13.               security problems surrounding  use  of  the  -exec  option;  you
  14.               should use the -execdir option instead.

复制代码

当command运行时,以参数{}替代当前文件。后面跟着带一个转义分号(\;)的整个序列。
回复 支持 反对

使用道具 举报

发表于 2005-6-22 15:13:18 | 显示全部楼层
Post by 河边星星
看了說明也不太了解...

?例呢/

+ 是只包括 , 比如find ./ -perm  +6000  就是设置了4000 (suid) 或 2000 (sgid)或者两者都设了 的所有文件
-   是确认某些部分, 比如find ./ -perm  -6000 就是同时设置了4000 (suid) 和2000 (sgid) 的所有文件。

不加+ 或-  就是完全匹配!
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-6-22 21:31:32 | 显示全部楼层
真心感謝樓上的,下次我會再多看一下man...

   exactly

+ any (文件任一部分許可權在指定的許可權分解之中即可)
Any of the permission bits mode are set of the file.
如樓上所術
find . -perm +6000 (4000 2000)只要?M足一個就可以找到了。


-  all   (文件許可權全部包含了指定的許可權即?M足)
All of the permisson bits mode are set of the file.

find .  -perm -6000 ( 4000 2000)此時會把如7000(4000 2000 1000)這個文件顯示出現,因為6000的所有都在7000之中。。。


以上為讓自己更熟練一此。。。再次感謝樓上的幾位。。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表