20150830-linux File Finder Tool

Source: Internet
Author: User
Tags glob

To be perfected ....


File Lookup:

The process of locating a qualifying file on a file system;


File Lookup: Locate, find

Locate: A non-real-time lookup tool that relies on a pre-built index, which is built automatically when the system is idle (periodic tasks), manually updating this database (updatedb), searching fast, and fuzzy lookups;

Find: real-time search; search speed slightly slow; exact search;


Find command:

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;



Search criteria:

To find by file name:

-name "file name": Supports the use of glob;

*, ?, []

-iname "file name": Character case insensitive, supports use of glob;


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


According to the genus, the genus Group looks for:

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


-group GROUPNAME:


-uid UserID: A file that finds the owner-specified UID of a file;

-gid GroupID:


-nouser: Find files that are not owned by the master;

-nogroup: Find files without a group;


To find by file type:

-type type

F: Normal file

D: Catalogue

L: Symbolic Link

B: Block device

C: Character device

P: Named Pipes

S: Socket


Combination Lookup criteria:

and Conditions:-A

or condition:-O

Non-conditional:-not,!


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

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


Depending on the file size, look for:

-size [+|-] #UNIT

Unit: K, M, G


#UNIT: (#-1,#]

+ #UNIT: (#,+oo)

-#UNIT: [0,#-1]


Based on time stamp:

In "Days" as the unit

-atime [+|-]#

#:[#,#+1)

+#: [#+1,oo]

-#: [0,#]

-mtime

-ctime


In "Minutes" units

-amin

-mmin

-cmin


Based on permissions:

-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;


Handling actions:

-print: Default handling action

-ls: Similar to the "ls-l" operation for each file found;

-delete: Delete the found file;

-fls/path/to/somefile: The detailed path information of the found file is saved to the specified file;


-ok COMMAND {} \;

The user must be confirmed beforehand before executing the specified command for each file;

-exec COMMAND {} \;

No user confirmation required;


Practice:

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

2. Find all files that are not root, bin or hadoop under the/usr directory;

3. Find all files whose contents have been modified and are not root or Hadoop for the last week in/etc directory;

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;

5. Find all files of more than 20k and type of ordinary person in/etc directory;

6, look for all the users in/etc directory do not have permission to write files;

7. Find at least one class of users who do not have permission to execute files in/etc directory;

8, find/etc/init.d directory, all users have execute permission, and other users have write permission files;


This article is from "I take fleeting chaos" blog, please be sure to keep this source http://tasnrh.blog.51cto.com/4141731/1694472

20150830-linux File Finder Tool

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.