码迷,mamicode.com
首页 > 系统相关 > 详细

Linux find 小练习

时间:2014-06-10 23:37:02      阅读:387      评论:0      收藏:0      [点我收藏+]

标签:linux   find   

1.任务一

查找/var目录下属主为root并且属组为mail的所有文件

[root@localhost ~]# find /var -user root -a -group mail
/var/spool/mail
/var/spool/mqueue
[root@localhost ~]#


2.任务二

查找/usr目录下不属于root,bin,或zhangfengzhe的文件

[root@localhost ~]# find /usr  not \( -user root -o -user bin -o -user zhangfengzhe  \)


3.任务三

查找/etc目录下最近一周内内容修改过且不属于root及zhangfengzhe用户的文件

[root@localhost ~]# find /etc not \( -user root -o -user zhangfengzhe \) -mtime -7
/etc
/etc/group-
/etc/blkid
/etc/blkid/blkid.tab.old
/etc/blkid/blkid.tab
/etc/printcap
/etc/gshadow
/etc/shadow
/etc/asound.state
/etc/avahi/etc/localtime


4.任务四

查找当前系统上没有属主或属组且最近1天内曾被访问过的文件,并将其属主属组均修改为root.

[root@localhost ~]# find .  \( -nouser -o -nogroup \) -atime -1 -exec chown root.root {} \;


5.任务五

查找/etc目录下大于1M的文件,并将其写入/tmp/etc.largefiles文件

[root@localhost ~]# find /etc -size +1M  -exec echo {} >> /tmp/etc.largefiles \;
[root@localhost ~]# cat /tmp/etc.largefiles 
/etc/selinux/targeted/policy/policy.21
/etc/selinux/targeted/modules/active/base.pp
/etc/selinux/targeted/modules/active/base.linked
/etc/selinux/targeted/modules/active/policy.kern
/etc/gconf/schemas/apps_nautilus_preferences.schemas
/etc/gconf/schemas/metacity.schemas
/etc/gconf/schemas/gnome-terminal.schemas
/etc/gconf/schemas/gok.schemas
/etc/gconf/gconf.xml.defaults/%gconf-tree.xml

或者

[root@localhost ~]# find /etc -size +1M >> /tmp/etc.largefiles



6.任务六

查找/etc目录下所有用户都没有写权限的文件,显示出其详细信息
[root@localhost ~]# find /etc not -perm -222 -exec stat {} \;



本文出自 “我想超越自我” 博客,请务必保留此出处http://zhangfengzhe.blog.51cto.com/8855103/1423662

Linux find 小练习,布布扣,bubuko.com

Linux find 小练习

标签:linux   find   

原文地址:http://zhangfengzhe.blog.51cto.com/8855103/1423662

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!