Linux Find command details and case description __linux

Source: Internet
Author: User

Find: Searching for files or directories
Example: Find. -name ' *.jsp '-mtime-90//Find files modified in JSP suffix within 90 days of current directory
-name: Search by name, support Glob wildcard *? [] and so on
-iname: Ignore name case
-empty: Find all empty files or empty directories, except connecting empty files
-user USERNAME: Find a Master file
-group Grpname: Find a group of files
-uid: Find related files based on the owner ID
-gid: Find related files based on group ID
-nouser: Find files that are not owned by the owner
-nogroup: Find files with no group
-exec: Execute command on found file (fixed format: '-exec command {} \; ') Do not ask. -ok ask for confirmation before execution.    Format '-ok command {} \; ' where ' {} ' represents the result of the Find query, ' \ ' is an escape character, indicating that some command or compliance with the meaning of the use itself
Example: Find.  -size +10m-exec ls-lh {} \; Look for more than 10M in the current directory and display more information


Group Lookup Criteria
-A: With
-O: Or
-not or!: Non-
Example: Find/etc-name ' init* '-a-user root//lookup/etc directory, file name begins with init and file owner is root


-type is based on file type lookup. F: Binary file L: Soft connection file D: Directory
-size +[-]unit represents a file greater than or less than
Tip: When retrieving file size, the black data block size of Linux is converted so that the query is faster and more accurate. For example: centos5.5 's black size is 512 bytes, looking for a file larger than 100M command is: find/etc-size +204800//Find files larger than 100M under/etc

Example: Ls-ldh ' find/etc/-size +2k '//view files larger than 2k in the/etc directory
Ls-ldh ' find/etc/-size-2k '//view files less than 2k in the/etc directory
Find/etc-size +163840-a-size-204800//Find files larger than 80M below 100M under/etc


Find by Timestamp:
-amin [files accessed +/-]n:n minutes ago
-mmin [Files modified +/-]n:n minutes ago
-cmin [+/-]n:n minutes ago changed files
-atime: [+/-]n files accessed in n days
-mtime: [+/-]n modified files in n days
-ctime: [+/-]n files changed in n days
Where: C for change changes, indicating that the file attributes have been modified, owners, groups, permissions and so on; A is accessed by access, indicating that the file has been accessed; M modified for modify to indicate that the contents of the file have been modified-: indicated within the specified value;


-inum: Lookup based on File I node (inode value) (ls-i file to show Inode)
Example: Find/data-name ' *.log '-a-inum 767301-exec rm-rf {} \; Find files with a. Log ending with an inode value of 7673016 in the/data directory, and then force the deletion




To find a file based on permissions:
-perm node: A file example that looks for the specified permission precisely: Find/etc-perm 755//Find a file with permission 755 in the ETC directory
-perm-node: Files in the corresponding permission range (in accordance with the conditions of the relationship) Example: find/etc-perm-755//Find a file for etc directory subordinate, group, other permissions are greater than 755 (that is, the existence of a permission corresponding to the containing relationship)
Example: find/data-perm-002//Find files that other users can write under the data directory
-perm/node find the corresponding permission bit and the condition or relationship of the file


Similar function command: Locate looking for files or directories (is found in the Linux system catalog files database, the result will be delayed, to be able to manually perform UpdateDB update system catalog file database)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.