admin管理员组

文章数量:1593485

开始想用find解决,find有针对权限的参数-perm。

仔细想想觉得权限的排列组合虽然不算太多,但是用数字不直观,容易乱,还是决定用正则来判断简单。

分四步来处理,第一步:

针对属主是root的文件

第二步:

针对属主不是root,但是组属性与root组相同的文件

第三步:

针对属主不是root,也不同组的文件

最后合并三次的结果进行计算。

累了,明天发代码。

-----代码来了-----

 #属主是root的可执行文件

 find -maxdepth 1 -type f -uid 0 -exec  ls -l {} \; |awk '{if($3=="root") print $0}' | egrep "(^-..x|^-..-..-..x|^-..-..x)"  >> execlist.txt

 #跟root同组的可执行文件

 find -maxdepth 1 -type f  -exec  ls -l {} \; |awk '{if($3!="root"  && $4=="root") print $0}'|egrep "(^-..-..-..x|^-..-..x)">>  execlist.txt

#不同组的可执行文件

 find -maxdepth 1 -type f  -exec  ls -l {} \; |awk '{if($3!="root"  && $4!="root") print $0}'|egrep "^-........x" >>  execlist.txt
#排序后排重,计算总数
sort execlist.txt | uniq | wc -l

本文标签: 小技巧可执行文件用户目录下Shell