1. locate --- & gt; search for the database generated in advance, fuzzy search, updatedb update the locate database-I: ignore the case of the file name-n: only show the first n rows of eg: lo
1. locate ---> searches for the database generated in advance, fuzzy searches, and updatedb updates the locate database.
-I: ignore the case sensitivity of file names.
-N: only show the first n rows. for example: locate-n 3 passwd
2. find ----> Real-time search, exact matching of file names
Find [DIR...] [CRIERIA] [ACTION...]
DIR:/root/home .. (default current directory)
ACTION;
-Print (default)
-Ls
-OK COMMAND: interactive COMMAND execution
-Exec COMMAND: non-interactive COMMAND execution
Xargs executes and creates commands from standard output
Eg; find/root-name "[[: alpha:] [[: digit:]"-exec mv {}{}\; // {} indicates the search result, which must end \;
Find/root-name "[[: alpha:] [[: digit:]" | xargs chmod 755
CRIERIA:
-Name: accurate to the specified file name
-Iname: search by file name, but case insensitive
-User: search by owner
-Group: search by group
-Uid: search by uid
-Gid: search by gid
In the specified time range:
-Atime: [+/-] N (access time): +-indicates --- (+) ---- N --- (-) ---- currentday
Eg: find-atime-3-exec ls-l {}\;
-Mtime: (modification time) Same as above
-Ctime (change time) Same as above
-Amin is in the same unit as preceding.
-Mmin
-Cmin
-Access closer to anewer a.txt than a.txt
Eg: find-anewer sh01.sh-exec ls-l {}\;
-Newer is equivalent to modification time
-Cnewer is equivalent to change time.
-Type: search by type
D (directory), l (link file), f (common file), s (socket file ),
B (block device), c (character device), p (command pipeline file)
Eg: find/var-type l-exec ls-l {}\;
-Size: search by size
[+/-] N
-Perm [+/-] mode: find permissions
Mode 755
-222 each type of user must match
Eg: find/tmp/myscrip-perm-001
/222 if a user has one type of permissions
-Nouser: no user
For example: find/-nouser to view files without a user name, this file is generally dangerous.
-Nogroup: no group
Search condition connection:
-A: & generally can be omitted
Eg: find-user root-type f-exec ls-dl {}\;
-O: |
Eg: find-user named-o-type d-exec ls-ld {}\;
-Not or! :!
Eg: find-not \ (-type d-a-user root \)-exec ls-ld {}\;
-Ls-l 'find/-name passwd'
Wildcard File name: * any character ,? Single character, []
Eg: find/tmp-name a * // search for files starting with