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

  • 相关阅读:
    C# 异步编程 (12)
    C# 动态语言扩展(11)
    C# LINQ(10)
    代码整洁之道(1)
    C# 集合(9) 持续更新
    C# 字符串和正则表达式(8) 持续更新
    C# 委托、lambda表达式和事件 (7) 持续更新
    C# 运算符和类型强制转换(6) 持续更新
    C++_将图二维矩阵形式转为邻接表结构
    .NET(C#)连接各类数据库-集锦
  • 原文地址:https://www.cnblogs.com/thlzhf/p/3465833.html
Copyright © 2011-2022 走看看