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
This article is from the "IT dream-qi-sharing" blog