zoukankan      html  css  js  c++  java
  • RH033读书笔记(12)-Lab 13 Finding and Processing Files

    Sequence 1: Using find

    Scenario: Log in as user student. Devise and execute a find command that produces
    the result described in each of the following problems, then write down the
    command in the space provided.

    You may need to refer to the man page for find. Remember that you can search
    man pages with /string.

    You will encounter a number of Permission denied messages when
    find attempts to recurse into directories to which you do not have read access -
    do not be concerned about these messages. Better yet, you can suppress these
    error messages by appending your find command with 2> /dev/null.

    Instructions:

    1. Produce a listing of everything under /var/lib owned by user rpm.

    find /var/lib -user rpm 2> /dev/null

    2. Produce a listing of everything under /var owned by user root and group mail.

    find /var -user root -group mail 2> /dev/null

    3. Produce an ls -l style listing of everything on the system not owned by users root, bin or
    student

    This will take a long time, so run the command in one terminal and do the next problem in
    another terminal while it runs.

    find / -not -user root -not -user bin -not -user student -ls 2> /dev/null
    or
    find / ! -user root ! -user bin ! -user student -ls 2>/dev/null

    4. Produce an ls -l style listing of everything under /usr/bin with size greater than 50
    kilobytes

    find /usr/bin -size +50k -ls 2> /dev/null

    5. Execute the file command on everything under /etc/mail

    find /etc/mail -exec file {} ; 2> /dev/null

    6. Produce an ls -l style listing of all symbolic links under /etc

    Hint: man find and search for an option that searches for files by type

    find /etc/ -type l -ls 2> /dev/null

    7. Produce an ls -l style listing of all "regular" files under /tmp that are owned by user
    student, and whose modification time is greater than 120 minutes ago.

    Hint: man find and search for an option that searches by modification time in minutes

    find /tmp -user student -mmin +120 -type f -ls 2> /dev/null

    8. Modify the command above to find all "regular" files under /tmp that are owned by user
    student, and whose modification time is greater than 120 minutes ago, and have find
    prompt you interactively whether or not to remove each one. Because you are using the
    interactive option, do not throw out error messages; that is, do not end your command with
    2> /dev/null. Decline to remove all files when prompted.

    find /tmp -user student -mmin +120 -type f -ok rm {} ;

    Note: The standard error is not redirected in answer number 9 because that would prevent
    the questions being asked by -ok from being displayed.

    9. Produce a listing of all files under /bin and /usr/bin that have the SetUID bit set.

    find /bin /usr/bin -perm -4000 2> /dev/null
    or
    find /bin /usr/bin -perm -u+s 2> /dev/null

  • 相关阅读:
    netbeans中给jpanl添加背景图片制定代码的理解——匿名内部类继承父类
    关于 ASP.NET MVC 中的视图生成
    Python的descriptor (2)
    分享php中四种webservice实现的简单架构方法及实例
    Python 中的 is 和 id
    Python的OO思想
    Python异常记录
    Python单例模式研究
    Python基础笔记
    python 映射列表 学习
  • 原文地址:https://www.cnblogs.com/thlzhf/p/3465833.html
Copyright © 2011-2022 走看看