The use of the CentOS system find

Source: Internet
Author: User

Find:

Function: Completes the file lookup by traversing the file system hierarchy under the specified starting path.

Working characteristics: Slow to find, exact search, fact finding;

How to use: Find [find starting path] [find condition] [processing action]

Find the starting path: Specify a specific search target starting path, default to the current directory;

Search criteria: The specified search criteria, can be based on the file name, size, type, engaged in relations, permissions and other criteria, the default is to find out the path of all the files;

Handling actions: Actions that are made on files that match the search criteria, such as deletions, which are output to standard output by default ;

Search criteria:

Expressions: Made up of options and tests

Search by file name:

-name "pattern"

-iname "pattern"

Supports GLOB-style wildcard printable in regular expressions *,?, [], [^]

-regex pattern: Finds a file based on a regular expression pattern, which matches the entire path, not its name;

find based on file affiliation:

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

-group GRPNAME: Finds all files belonging to the specified group of groups;

-uid uid: Finds all files that belong to the UID specified by the master;

-gid GID: Finds all files belonging to the specified GID of the group;

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

-nogroup: Find files without a group;

Find by file type:

-type Type:

F: Normal file

D: Catalog file

L: Symbolic Link file

B: Block device files

C: Character device file

P: Pipeline File

S: Socket file

Combination test:

With:-A, default combination logic;

Or:-O

Non:-not,!

Find by file size:

-size [+|-] #UNIT

Common units: K, M, G

#UNIT: (#-1, #)

-#UNIT: [0,#-1]

+ #UNIT: (#, OO)

Find by Time stamp:

In "Days" as the unit:

-atime [+|-]#

#:[#, #-1)

-#: (#, 0]

+#: (Oo, #-1)

-mtime

-ctime

In "Minutes" units:

-amin Access Time

-mmin modification Time

-cmin

Search by permissions:

-perm [/|-]mode

Mode: precise permission matching;

/mode: Any one (r,w,x) of the permissions of any class of users (U,g,o) is satisfied with the condition;

There is a "or" relationship between 9-bit permissions;

-mode: Each class of users (U,g,o) in the permissions of each bit (r,w,x) at the same time meet the condition is satisfied;

There is a "and" relationship between 9-bit permissions;

Handling actions:

-print: Output to standard output, default action;

-ls: Similar to the "ls-l" command for the found file, the output file details;

-delete: Delete the found file;

-fls/path/to/somefile: Saves the long format information of all files found to the specified file;

-ok COMMAND {} \; : Executes commands for each file that is found, and each operation is confirmed by the user;

-exec COMMAND {} \; : Executes commands for each file that is found;

Note: Find passes the file path found to the following command, it is first to find out all eligible file paths, and one-time pass to the following command;

However, some commands cannot accept too long arguments, at which point the command execution fails, and another way to circumvent this problem: find | Xargs Comman

Security Context

1, the process to run the identity of users; A process is the agent that initiates the user of this process, and therefore completes all operations with the identity and permissions of the user;

2. Permission Matching model:

Determines whether the owner of the process is the owner of the file being accessed, or if the owner's permission is applied, otherwise the Access file is not specifically defined to the user's access control list, if any, then the second step;

The owner of the second judgment process, whether it belongs to the file belonging to the group; if it is, the permissions of the group are applied, otherwise the access control list is not specifically defined to the user; otherwise, the third step is entered;

three permission to apply other;



The use of the CentOS system find

Related Article

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.