Find [Find location] [find standard] [processing action]
Find a path: Default current directory
Find Standard: Default to all files under the specified path
Processing Operations: Default is Display
Matching Criteria:
-name ' filename ': on file name
File name wildcard:
*: Any character of any length
?
[]
-iname ' filename ': file name matching is case insensitive
-regex PATTERN: File name wildcard based on regular expressions
-uid UID: Search by UID
-gid GID: Search by GID
-nouser: Finding files that are not owned by the master
-nogroup: Finding files that are not owned by a group
-type
F: Ordinary document (f)
D: Catalog file
B: Block devices (blocks)
C: Character device file (character)
L: Symbol device files (symbolic link file)
P: Command pipe file (pipe)
S: Socket file (socket)
-size[+|-]
#k: [plus | minus] accurate to 10k
#M
#G
Combination Conditions:
-A and
-O or
-not Non-
/tmp directory, not a directory, and a file that is not a socket type
Find./-not \-user User1-o-type D
Find./-not \ (-user user1-a-type D)
/tmp/test directory, the owner is not user1, nor is it a user2 file
Find./-not \-user user1-a-user user2
Find./-not \ (-user user1-o-user user2)
Modification Time
-mtime
-ctime
-atime
[+|-]# (digital)
+5:5 days ago
Visited within -5:5 days
5: Just over the last 5 days have visited
-mmin
-cmin
-amin
[+|-]#
+5:5 minutes ago
-5: Accessed within 5 minutes
5: Just over 5 minutes have visited
find based on permissions
-perm Mode Exact Search
/mode: Only one file match is required to display
-mode: File permissions can only be displayed when the MODE is fully contained
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/7E/3B/wKioL1b6PMPjfTQqAADRtPDOHJ8553.png "title=" Find1.png "alt=" Wkiol1b6pmpjftqqaadrtpdohj8553.png "/>
Operation :
-printf: Display
-ls: Displays details of each file similar to Ls-l
-ok COMMAND {}\; Further operations on files based on the found file (user confirmation is required for each step)
-exec COMMAND {}\; Further action on the file (no confirmation required)
Be sure to end or syntax error
{}: Reference file file name placeholder
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/80/1F/wKiom1c4USSy3LmpAAOnYuEztqU647.jpg "title=" Find2.jpg "alt=" Wkiom1c4ussy3lmpaaonyueztqu647.jpg "/>
EG1. Locate the directory file, remove the execution permissions of the group, and remove other users ' Read permissions
EG2. Locate file A with Write permission for the group and rename it to A.new
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/80/1C/wKioL1c4Ub-iHpPxAABLcoZAF4E469.jpg "style=" float: none; "title=" find3.jpg "alt=" Wkiol1c4ub-ihppxaablcozaf4e469.jpg "/>
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/80/1C/wKioL1c4UcGSqmZgAAIKxqIkA1s793.jpg "style=" float: none; "title=" find4.jpg "alt=" Wkiol1c4ucgsqmzgaaikxqika1s793.jpg "/>
650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/80/1F/wKiom1c4UWPxw834AASz4Kern8E463.jpg "title=" Find5.jpg "alt=" Wkiom1c4uwpxw834aasz4kern8e463.jpg "/>
Practice 1. Find all files in the/var directory that are subordinate to the root and belong to the group GDM
Practice 2. Find files that are not part of the/usr directory root,bin, or Andy
Find/usr-not \ (-user root-o-user bin-o-user Andy \)
Practice 3. Find files that have been modified and are not root and Andy users in the/etc directory in the last week
Find/etc-ctime-7-a-not-user root-a-user Andy
Practice 4. Find files on the current system that are not owned by the master or group and have been accessed in the last 1 days and change their genus to root
Find./\ (-nouser-o-nogroup \)-a-ctime-1-exec-chown root:root {} \;
Practice 5. Find a file with a heavy rain 1M in/etc directory and write its file name to the/tmp/etc.largerfiles file
Find/etc-size +1m-exec {} >>/tmp/etc.largefiles \;
Find/etc-size +1m | Xargs echo >/tmp/etc.largefiles
Practice 6. Find files with no write permission for all users in/etc directory, showing their details
Find/etc-not-perm/222-exec-ls {} \;
650) this.width=650; "src=" http://s2.51cto.com/wyfs02/M01/80/1F/wKiom1c4UZWTe_WjAAOC2DE16ws258.jpg "style=" float: none; "title=" 7-3lx1.jpg "alt=" Wkiom1c4uzwte_wjaaoc2de16ws258.jpg "/>
650) this.width=650; "src=" http://s1.51cto.com/wyfs02/M02/80/1F/wKiom1c4UZeDDPoWAAIz1lj1WZg671.jpg "style=" float: none; "title=" 7-3lx2.jpg "alt=" Wkiom1c4uzeddpowaaiz1lj1wzg671.jpg "/>
650) this.width=650; "src=" http://s4.51cto.com/wyfs02/M00/80/1F/wKiom1c4UZiiDbkPAADqpaAfKeA225.jpg "style=" float: none; "title=" 7-3lx4.jpg "alt=" Wkiom1c4uziidbkpaadqpaafkea225.jpg "/>
650) this.width=650; "src=" http://s2.51cto.com/wyfs02/M02/80/1F/wKiom1c4UZnzSy_OAAGF454syao550.jpg "style=" float: none; "title=" 7-3lx5.jpg "alt=" Wkiom1c4uznzsy_oaagf454syao550.jpg "/>
special permissions
passwd:s
SUID: When you run a program, The owner of the corresponding process is the program file itself, not the initiator
chmod u+s file
chmod u-s file
If file itself has execute permission, SUID is displayed as S, otherwise s
SGID: When you run a program, the group of the corresponding process is the program file itself, not the base group that the initiator belongs to
chmod g+s file
chmod g-s file
Sticky: In a common directory, each can create files, delete its own files, but cannot delete others ' files
chmod o-t DIR
chmod o+t DIR
Four-digit permission, first bit is special permission
Sticky SGID suid
0 000 No special Permissions
1 001 only Sticky
2 010 only Sgid
3 011 have sgid and Sticky
4 100 only suid
5 101 have suid and Sgid
6 110 have suid and Sticky
7 1113 special permissions have &N bsp;
eg:5755/backup have suid and sticky
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M02/80/1F/wKiom1c4UTyyzZylAAOVqHHP3zk972.jpg "title=" Special permissions 1.jpg "alt=" Wkiom1c4utyyzzylaaovqhhp3zk972.jpg "/>
This article is from the "11160930" blog, please be sure to keep this source http://11170930.blog.51cto.com/11160930/1773668
2016-3-29 Linux Basic Learning--find command