Linux file Lookup mainly includes: Locate and find
1, locate
Simple to use, based on database lookup, not real-time, usage:
Locate FILENAME
Manually updating the database (time may be longer)
UpdateDB
2. Find
Real-time, accurate, powerful, usage:
Find Path Lookup Standard post-discovery action
(1) Path:. Or./both represent the current directory
(2) Search criteria:
' FILENAME ' Exact file name matching (wildcard *?) is supported. []) ' FILENAME ' file name fuzzy match (not case)-regex PATTERN Regular match
-user USERNAME based on owner lookup -Group group Search by genus -uid uid-gid gid-nouser No master File
-type lookup based on file type -type F file -typed directory -type C character device - Type B- block device -type L link -type P pipe -type s socket
-size lookup based on file size -size10k-size25M-size 3G-size +10k Files larger than 10k -size-5m files less than 5M
combination options:-a and-o OR-not not
Find-mtime time (default unit: Days)based on Times-ctime -atime -ctime +5 change time 5 days or more -access-3 access time within 3 days -mmin (Default unit: minutes)-cmin-amin
find based on permissions 755 Precise permissions -perm/644 Three-bit has a match to be -perm- the down contains (contains 600/ ..../)
Example 1: find generic files in/tmp directory without owner
Find /tmp-nouser-a-type D
Example 2: Find other files under/etc that are neither normal nor directory
find /etc-not \ (-type d-o-type f \)
(3) Post-search action
-Print default action -LS list -ok COMMAND \; Need to confirm execution command-exec command \; No need to confirm execution command
Example 3: Find all the files with permission 600 in the current directory and see their size ({} indicates the file found, \; indicates the Terminator)
Find - du {} \;
Example 4: Find a file with a permission of 400 in the current directory and add the prefix name to the. New
Find - mv {} {}.new \;
Linux file Lookup command find usage collation (locate/find)