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

  • 相关阅读:
    nginx: [emerg] the size 10485760 of shared memory zone "cache_one" conflicts with already declared size 0
    ruby 删除文件夹(包括文件夹中的文件夹和文件)
    nisi 脚本示例
    将node-expat扩展编译至node.exe中
    将odbc扩展编译至nodejs程序集中
    微信小程序数据传递基本
    Java环境配置
    Angular环境配置
    mysql中常用的数据类型
    html中a标签的4个伪类样式
  • 原文地址:https://www.cnblogs.com/thlzhf/p/3465833.html
Copyright © 2011-2022 走看看