Locate: The search speed based on the file database is fast, and Fuzzy Matching is supported.
-I case-insensitive
-N N: after finding the corresponding file, only the first N rows are displayed.
Updatedb: generated by the locate database, but the speed is slow. You need to traverse the file.
Find: Real-Time retrieval, exact matching of file names,
Format: find [DIR,...] [CRITERIA (rule)] [ACTION...]
[ACTION] default print
[CRITERIA (rule)]: default current directory
1. Search by File Name:
-Name: search by file name. Supports file name configuration *? []
Example: find/etc-name "passwd"
-Iname is case-insensitive.
2. Search by owner and group:
-User find/home-user redhat
Ls-l 'Find/home-user redhat'
-Group same as above
-Uid: the user is deleted and the file is not deleted. The owner uid of the file
-Gid
-Nouesr has no user
-Nogroup: No group
3. Search by attribute:
-Type f d l s B c p
-Cnewer attributes
-Newer content
-Size: according to the file size [+/-] N
Exception: find/etc-size 1 M find files smaller than 1 M
2 M indicates a file with a precision of 2 M + 1 M greater than 1 M
4. Permissions:
-Perm [-/] mode + is not commonly used
Find/tmp-perm 755 exact match
Find/tmp-perm-222 owner, group, and other user permissions must match
+ 222 the same as "/" has a type of matching
/777 match a permission match
/001 match the file with the execution permission
5. According to the file time:
-Atime example: find/etc-atime + 5 indicates files not accessed within five days. "-5" indicates files that have been accessed within five days.
-Mtime: Same as above
-Ctime: Same as above
-The amin time is measured in minutes.
-The usage of mmin is the same as that of mmin.
-Cmin: Same as above
-Anewer example: find/etc-annewer/etc/passwd access time earlier than passwd access time
ACTION:
-Print default
-Ls
-OK requires confirmation
-Exec COMMAND
Find./-perm/001-not-type d-exec chmod o-x {}\;
Find./-name "[[: alpha:] [[: digit:]"-exec mv {}{}. old \;
{} Indicates the previously found file name.
Find-name "*. old" | xargs chmod 755
This article is from the "Wei's Linux bar" blog