which: find binary or execute command path
[email protected] ~]# which free results:/usr/bin/free
Locate: non-real-time fuzzy query daily update
(with a built-in database, system files have a mapping in the database, instantly find the target file that was automatically updated the previous night)
-B Match base name
-C Statistics How many meet the conditions
UpdateDB Manual Update
Find: real-time, file traversal, exact matching, slightly slower speed
-A: with
-O: or
-not: non-priority, combined use to use grouping \ (\)
-fls /path/to/somefile Find after matching results to a file
-ok COMMAND {} results before interactive reference-ok
-exec command{} \;: direct reference to-exec previous results note the end of the ";"
Search based on file name:
Find/tmp-name ' passwd* '-ls----matching file named passwd followed by any character
Find/tmp-iname ' passwd* '-ls----case insensitive
Based on the owner, genus Group, UID lookup:
Find/tmp-user mysql-ls----MATCH/tmp subordinate main MySQL file find/tmp-group mysql-ls----Match/tmp subordinate group MySQL file
To find files that are not owned by the master:
Find/tmp-nouser
Delete files that are not owned by the master:
Find/tmp-nouser-exec rm{} \; -----exec non-interactive execution {} references the preceding result
Search based on file type:
find/etc/-type f/d/l/s/b/c/p----Find type files such as normal, directory, link, socket, etc.
Search by File Size: (If you are looking for 2k files 1-2k are 2k)
Find/etc-size 2k-ls----Check the file of 1-2k find/etc-size-2k-ls----0-1k file find/etc-size +3k-ls-a-size-9 K-ls----Check for files larger than 3k and less than 9k
Timestamp-based lookups:
Formula : # # days were changed #;[ #,#-1); #天内被改动-#:(#,0]; #天前被改动 +#:(00,#-1]
Understanding: Current time March 9 21 o'clock, query the file three days ago, the file time should be March 5 21 o'clock to negative infinity time, because the third day ago, excluding the third day, (before today, is yesterday's 23 points 59 minutes 59 seconds)
Find/var/log-mtime +3-type f-ls----> query three days ago normal file
Understanding: Current time March 9 21 o'clock, query the file within three days, the file should be March 6 21 o'clock to March 9 21 o'clock content, Comparison formula view
find/var/log-time-3-type f-ls----> Query normal files modified within three days
Understanding: Current time March 9 21 o'clock, query the third day of the file, the file should be March 6 21 o'clock to March 7 21 o'clock content, comparison formula to see Understanding
Find/var/log-mtime 3-type f-ls----> Query Third day revised general anthology that
Search based on permissions:
-perm
MODE: exact permission match
/mode:(u,g,o) The permission of an object can be matched as long as one has the same
-mode: Each class needs to match the owning
find/tmp-perm/400----> matches any kind of yo-read permission to match
Find/tmp-type F-perm/001-ls----> see which files are normal in the directory and other users have Execute permissions
Practical Practice:
Find all files or directories in the/var directory that are subordinate to root and belong to the group Mail
Find/var-user root-a-group Mail-ls
Find all files or directories that do not belong to root, bin, or Hadoop in the/usr directory
Find/usr-not \ (-user root-o-user bin-o-user hadoop \)-ls
Find the contents of the/etc directory in the last week, the content has been modified, and the owner is not root, is not a Hadoop file or directory
Find/etc-mtime-7-not \ (-user root-o-user hadoop \)-ls
Find files or directories on the current system that are not owned by the master or group and have been visited in the last week
Find/\ (-nouser-o-nogroup \)-atime-7-ls
Find all files that are larger than 1M in the/etc directory and are of the normal file type, and display them in megabytes
Find/etc-size +1m-type f-exec ls-lh {} \;
Find files in/etc directory where all users do not have permission to write
Find/etc-not-perm/222-type F-ls
Find at least one class of users who do not have permission to execute files in/etc directory
Find/etc-not-perm-111-type F-ls
Find the/etc/init.d/directory, all users have execute permissions, and other users have write permissions to the file
Find/etc/init.d-perm-113-type F-ls
Read the second query in/tmp, 60 seconds to access the file
Watch-n1 "Find/tmp-amin-60-type F"
With the script implementation, every night 4:30, find out/data/log/nginx the format "nginx-testxxx.log" Test log file, if the log is larger than 2M, then delete it, delete, delete the file name, record to/ TMP directory in the Rm.log file
4 * * * find/data/log/nginx-name ' nginx-test*.log '-size +2m-exec-fls/tmp/rm.log \;echo ' >/tmp/rm.log
This article is from the "11249394" blog, please be sure to keep this source http://11259394.blog.51cto.com/11249394/1749538
Text Lookup tool Find