How to Use the find-perm command in Linux

Source: Internet
Author: User
Tags html comment


Linux Command find-perm usage took some time to understand the-perm parameter of the find command in linux. Find-perm: find-perm modefind-perm-modefind-perm + mode. What are the differences between them? To explain the concept of File Permission bit in linux. In linux, the file or directory has three permissions: r, w, x, which indicate read, write, and executable. The attributes of a file or directory include the attributes of user u, group g, and other o, indicates the permissions of the user, group, and other users on the file. It looks like this: Another rwx user in the user group of www.2cto.com sets 1 on the bit with permissions, and the bit with no permissions is set 0. If you think of these permission bits in each part as the binary number, each part can be represented by three binary numbers. The maximum value is 7 (2 ^ 3-1 ), indicates readable, writable, and executable. Strictly speaking, apart from r, w, and x, file permissions also include setuid and setgid permissions. Now that you have the permission bit, let's look at find-perm mode. Mode is represented by three numbers, and the maximum value of each number is 7 (as described above ). Find-perm mode, which indicates a strict match. That is, if your File Permission bit is converted to the same decimal number as the mode, the match is successful, note that if the number given by mode is less than three digits, the preceding value is automatically 0 (strictly speaking, the number is less than four digits, because the setuid and setgid mentioned above are explained later) find-perm-mode, indicating that the mode must be converted to binary 1 and must match in the File Permission bit. For example, if mode = 644, the value is converted to binary 110 100, the permission bit of the file to be searched can also be converted into a binary number. The two must be in full match if they are in 1 position, and 0 does not matter. For example, if the permission of the file to be searched is to convert the file to a binary number of 111, 111, 111, and 100, the file is matched. If the permission is 100, 100, the file is not matched. So the role of '-' is to match files with more permissions than mode (No words can be found to describe) find-perm + mode, the difference with-mode is that + mode only needs to match the part of any one of them.-mode must be matched for all the parts of 1, and the + mode does not matter if it is 0. The setuid, setgid, and setuid permissions of www.2cto.com are used to allow other users to execute your commands "Beyond authorization". The essence of the implementation is that during the permission check, the UID of this other user is saved in the valid UID of the process, so the permission is verified with pride (here the http://www.bkjia.com/ OS /201205/130111.html comment 1 is a very simple introduction ), these permissions are represented by a new three-bit binary number, which has three values: 4 and 1. 4 indicates the setuid permission, 2 indicates the setgid permission, and 1 indicates the sticky bit (t) permissions (the most typical example of sticking bit permissions is/tmp. Each user can create, update, and delete files created by himself (the file owner is his/her own, but cannot change other people's files ). If you have any questions, please contact us ~ 1. http://bbs.chinaunix.net/thread-442733-1-1.html from ICER-REPLS 'blog

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.