Locate: the search speed based on the file database is fast, and fuzzy matching is supported. -I ignore case-nN find the corresponding file and only show the first N rows of updatedb: locate database generation, but the speed is slow, you need to traverse the file. find: real-time retrieval, exact matching of file names, format: f...
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