Exercise: 1. Find all files or directories in the/var/directory that are subordinate to the root and belong to the group Mail [[email protected] ~]# find /var/ -user root -group mail -ls263443 4 drwxrwxr-x 2 root mail 4096  AUG  7 09:10 /VAR/SPOOL/MAIL264398    4 -RW-RW---- 1 root mail  1924 JUL 31 16:45 /VAR/SPOOL/MAIL/JAY264569   72 -RW------- 1 root mail 67044 aug 7 09:10 /var/spool/mail/root2. Find all files or directories in the/usr/directory that do not belong to Root,bin or Hadoop In two ways, 1. [[email protected] ~]# find /usr/ -not -user root -a -not - User bin&nbsP;-a -not -user hadoop 2. [[Email protected] ~]# find /usr/ -not \ ( -user root -o -user bin -o -user jay \) 3. Find a file or directory in the last week of the/etc/directory whose content has been modified and is not the root user or Hadoop [[email protected] ~]# find /etc/ -mtime -7 -a -not -user root -a -not -user jay4. Find files or directories on the current system that do not have a master or a group and have been visited in the last week [ [email protected] ~]# find / -atime -7 -a -nouser -a - Nogroup -ls 5. Find all files that are larger than 1M in the/etc/directory and are of the normal file type [[email protected] ~]# find /etc/ -size +1m -a -type f -exec ls -lh {} \;6. Finding/etc/ Files in directory where all users do not have write permission "Look in the opposite direction" [[email protected] ~]# find / Etc -not -perm /222 -type f -ls7. Find/etc directory at least one class of users who do not have permission to execute [[Email protected] ~]# find /etc -not -perm -111 -type f -ls 8. Find/etc/init.d directory, all users are executed by permission, and other users have write permission to all files find linked files must add/ [[ Email protected] ~]# find /etc/init.d/ -perm -113 -type -f -ls 9. Find the owner must be a CentOS group of user1 or the master is CentOS and the name is F5 [[email protected] sbin]# ll total 0-rw-r--r--. 1 jay jay 0 aug 12 16:55 f1-rw-r--r--. 1 centos user1 0 aug 12 16:55 f2-rw-r--r--. 1 root root 0 aug 12 16:55 f3-rw-r--r--. 1 centos centos 0 aug 12 16:57 f4-rw-r--r--. 1 centos user2 0 aug 12 16:57 f5 [[email protected] sbin]# find -user centos -a \ ( - group user1 -o -name f5 \) -ls 1050330 0 - rw-r--r-- 1 centos user1 0 aug 12 16:55 ./f21050333 0 - rw-r--r-- 1 centos user2 0 aug 12 16:57 ./f5
This article from "Mylinux" blog, declined reprint!
Find command exercises ' small trial sledgehammer '