码迷,mamicode.com
首页 > 其他好文 > 详细

文件查找 find

时间:2015-08-11 19:04:24      阅读:132      评论:0      收藏:0      [点我收藏+]

标签:find

find 查找路径 查找标准 处理动作

范例

     find /etc -name ‘passwd’  根据文件名查找

     find ./-perm 644            查找文件权限为644的

     find ./-mmin -5             五分钟之内访问过的文件有哪些

     find /etc -size 10k         所有9-10K的文件

     find /etc -size -10k        所有小于10k的

     find /tmp -nouser -a -type d找tmp下没有属主,并且类型为目录的      

            -type

f:普通文件

d:目录

  find /tmp -type d ()

c:字符设备

b:块儿设备

l:符号设备

p:管道设备

I:套接字类型

     find ./ \( -nouser -o -nogroup \) -a -atime -1 -exec chown root:root {} \;

      这类文件很有可能被人利用,对公司造成损失


     find ./ -atime -3           三天之内访问过的文件

     find ./ -atime +3           有三天没有访问的文件        

                -mtime 修改的时间

                -atime 访问的时间  天

                -ctime 的时间

                -mmin

                -cmin 分钟

                -amin

find /etc -size +1M -exec echo {} >> /tmp/file.txt

find /etc -size +1M | xargs echo >> /tmp/file.txt

第一种是一行一行的   

第二种是以空格为分隔的文本

       




练习题全会基本没有问题:

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

        find /var -user root -a -group mail


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

find /usr -not -user d root -a -not -user bin -a -not student

find /usr -not \(-user d root -o -user d bin -o -user d student \)  

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

find /etc -mtime -7 -not -user root -a -user student 

find /etc/-mtime -7 -not \( -user root -o -user student \)


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

find ./ \( -nouser -o -nogroup \) -a -atime -1 -exec chown root:root {} \;


5、查找/etc目录下所有用户都没有写权限的文件,显示出其详细信息;

  find /etc -not -perm /222  -ls


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

  find /etc. -size +1M >> /tmp/etc.largefiles

find /etc -size +1M | xargs echo >> /tmp/etc.largefiles


文件查找 find

标签:find

原文地址:http://10183596.blog.51cto.com/10173596/1683746

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