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: show only the first n rows eg: locate-n3passwd
2. find ----> real-time search, exact matching of file names
Find [DIR...] [CRIERIA] [ACTION...]
DIR:/root/home .. (default current directory)
ACTION;
-Print (default)
-Ls
-OkCOMMAND: Interactive Command Execution
-ExecCOMMAND: non-interactive Command Execution
Xargs executes and creates commands from standard output
Eg; find/root-name "[[: alpha:] [[: digit:]"-execmv {}{}\; // {} indicates the search result, which must end \;
Find/root-name "[[: alpha:] [[: digit:]" | xargschmod755
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 (accesstime): +-represents --- (+) ---- N --- (-) ---- currentday
Eg: find-atime-3-execls-l {}\;
-Mtime: (modificationtime) Same as above
-Ctime (changetime) is the same as above
-Amin is in the same unit as preceding.
-Mmin
-Cmin
-Anewera.txtcloser access than a.txt
Eg: find-anewersh01.sh-execls-l {}\;
-Newer is equivalent to modificationtime
-Cnewer is equivalent to changetime.
-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-typel-execls-l {}\;
-Size: search by size
[+/-] N
-Perm [+/-] mode: Find Permissions
Mode755
-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-userroot-typef-execls-dl {}\;
-O: |
Eg: find-usernamed-o-typed-execls-ld {}\;
-Notor! :!
Eg: find-not \ (-typed-a-userroot \)-execls-ld {}\;
-Ls-l 'Find/-namepasswd'
Wildcard file name: * any character ,? Single character, []
Eg: find/tmp-namea * // search for files starting with