A summary of the use of the file finding find

Source: Internet
Author: User
Tags glob

Find command format:


Find [OPTION] ... [Find Path] [Search Criteria] [Handling Action]
Find path: Default to the current path;
Search criteria: The specified search criteria, can be based on the file name, size, genus of the main group, type, etc., by default to find all the files under the specified path;
Handling actions: What to do with the eligible files; By default, output to the screen;

1, according to the file name to find:

                -name "file name" : Supports the use of glob;
                     650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; margin:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" image "border=" 0 "alt=" image "src=" http://s3.51cto.com/wyfs02/M01/72/D1/ Wkiom1xtnoss6019aabd_jaqg2a044.jpg "" 336 "height="/>
                 -iname "file name": Character case insensitive, glob supported;

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" image "border=" 0 "alt=" image "src=" http://s3.51cto.com/wyfs02/M02/72/D1/ Wkiom1xtnotihxvnaaa4s8cai_e138.jpg "" 323 "height="/>

-regex "pattern": matches the entire file path string with pattern, not just the file name;

2, according to the owner, belong to the group search:

-user USERNAME: Find files belonging to the owner of the specified user;

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; margin:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" image "border=" 0 "alt=" image "src=" http://s3.51cto.com/wyfs02/M00/72/D1/ Wkiom1xtnoxg4nnoaablvibkkne047.jpg "" 613 "height="/>

-group GROUPNAME: Find the genus group designated file;

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; margin:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" image "border=" 0 "alt=" image "src=" http://s3.51cto.com/wyfs02/M01/72/D1/ Wkiom1xtnoxr071haabybsftlys097.jpg "" 613 "height="/>

3. Search by File type:

-type type
                     f: normal file
                     d: Catalog
                     L: Symbolic link
                     B: Block device
                     C: Character device
                     P: Named Pipes
                     S: Socket

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; margin:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" image "border=" 0 "alt=" image "src=" http://s3.51cto.com/wyfs02/M02/72/D1/ Wkiom1xtnowhaoogaaaznr6ugak958.jpg "" 277 "height=" "The/>

4. Combination search criteria:

and Conditions:-A

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; margin:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" image "border=" 0 "alt=" image "src=" http://s3.51cto.com/wyfs02/M00/72/CD/ Wkiol1xtnw-cpacmaabt1jirpos443.jpg "" 613 "height="/>
or condition:-O
Non-conditional:-not,!

! A-o! B =! (A-a B)
! A-a! B =! (A-o B)

5, according to file size to find:

-size [+|-] #UNIT
Unit: K, M, G

#UNIT: (#-1,#]
+ #UNIT: (#,+oo)
-#UNIT: [0,#-1]

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; margin:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" image "border=" 0 "alt=" image "src=" http://s3.51cto.com/wyfs02/M01/72/CD/ Wkiol1xtnxdh8jo2aac8hdltayq361.jpg "613" height= "/>"

6, according to time stamp:

In days
                    -atime [+|-]#
                         #:[#,#+1)
                         +# : [#+1,oo]
                        -#: [0,#]
                    -mtime
                    -ctime

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; margin:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" image "border=" 0 "alt=" image "src=" http://s3.51cto.com/wyfs02/M02/72/CD/wKioL1XtnxDDO_ Vvaabu-t2-i44513.jpg "" 613 "height="/>

In "Minutes" units
-amin
-mmin
-cmin

7, according to the authority:

-perm [/|-]mode
MODE: Exact permission match
/mode: Any one of a class of objects (U,g,o) is eligible for any of the rights, implied or conditional;
/400
-mode: Every permission specified for each class of object must be in accordance with the condition;

Practice:

1, find the/var directory is the owner of the root, and belong to the group mail all files;

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; margin:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" image "border=" 0 "alt=" image "src=" http://s3.51cto.com/wyfs02/M00/72/CD/ Wkiol1xtnxgwjcihaabznisqtnu985.jpg "" 613 "height="/>
2. Find all files that are not root, bin or hadoop under the/usr directory;

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; margin:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" image "border=" 0 "alt=" image "src=" http://s3.51cto.com/wyfs02/M02/72/CD/ Wkiol1xtnxgjhq3kaadelloocnc227.jpg "" 613 "height="/>
3. Find all files whose contents have been modified and are not root or Hadoop for the last week in/etc directory;

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; margin:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" image "border=" 0 "alt=" image "src=" http://s3.51cto.com/wyfs02/M01/72/D1/ Wkiom1xtnoiyscafaab6wnirf-k861.jpg "" 613 "height="/>
4. Find all files on the current system that are not owned by the master or group, and have been visited in the last week;

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; margin:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" image "border=" 0 "alt=" image "src=" http://s3.51cto.com/wyfs02/M00/72/CD/ Wkiol1xtnxltmjjraacmnolkfwc297.jpg "" 613 "height="/>
5. Find all files of more than 20k and type of ordinary person in/etc directory;

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; margin:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" image "border=" 0 "alt=" image "src=" http://s3.51cto.com/wyfs02/M01/72/CD/ Wkiol1xtnxbc7nsgaakf_jhuyou135.jpg "" 613 "height=" 236 "/>
6, look for all the users in/etc directory do not have permission to write files;

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; margin:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" image "border=" 0 "alt=" image "src=" http://s3.51cto.com/wyfs02/M02/72/CD/ Wkiol1xtnxfymd6xaatwwaoweno007.jpg "" 613 "height=" 460 "/>
7. Find at least one class of users who do not have permission to execute files in/etc directory;

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; margin:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" image "border=" 0 "alt=" image "src=" http://s3.51cto.com/wyfs02/M00/72/CD/wKioL1XtnxiS4_ N7aar5iuxe3rq116.jpg "" 527 "height=" 460 "/>
8, find/etc/init.d directory, all users have execute permission, and other users have write permission files;

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; margin:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" image "border=" 0 "alt=" image "src=" http://s3.51cto.com/wyfs02/M01/72/CD/ Wkiol1xtnxmhqnpgaar5xk8p5nq169.jpg "" 613 "height=" 417 "/>

A summary of the use of the file finding find

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.