Special file permissions in Linux have been working on Samba service configurations today, and they are deeply aware of the difficulty of permission control. The file permission mechanism is a major feature of Linux systems, in addition to the Read (r), write (w), and execute (x) permissions we are familiar with, there are three special permissions... special file permissions in Linux have been working on Samba service configurations today, and they are deeply aware of the difficulty of permission control. The file permission mechanism is a major feature of Linux systems, in addition to the Read (r), write (w), and execute (x) permissions we are familiar with, there are three special permissions: setuid, setgid, and stick bit ). 1> setuid and setgid are used in the system. take/etc/passwd and/usr/bin/passwd as examples: [plain] [root @ Salve1 school] # ll/etc/passwd/usr/bin/passwd-rw-r -- 1 root 2005 Apr 23/etc/passwd- rwsr-xr-x 1 root 23420 Aug 11 2010/usr/bin/passwd [root @ Salve1 school] # analyze, the permission for/etc/passwd is-rw-r -- that is, the owner of the file has the read and write permissions, and the user group and other members only have the viewing permission. We know that in the system, we need to modify the password of a user. for root users and general users, we can use the/usr/bin/passwd someuser command to modify the/etc/passwd file, the root user has write permissions on/etc/passwd, which is understandable. for normal users, setuid is used here, the role of setuid is "to allow the user who executes the command to execute the command with the permission of the command owner", that is, the common user will have the root permission when executing passwd, in this way, you can modify the/etc/passwd file. It is marked as "s" and will appear in the place of "x", for example, "-rwsr-xr-x. The setgid is the same as the setgid, that is, it allows the user of the execution file to execute with the permissions of the group to which the file belongs. 2> stick bit (stick bit: [plain] [root @ Salve1/] # ll-d/tmp drwxrwxrwt 13 root 4096 Apr 23/tmp [root @ Salve1/] # We know that/tmp is temporary file Directory, all users have all permissions under this directory, that is, they can create, modify, and delete files under this directory. if user A creates A file under this directory, user B deleted the file, which is not allowed. To achieve this goal, the stick bit concept emerged. It is for a directory. If stick bit is set for this directory ), in addition to the creator and root user of the file, the files in the directory can delete and modify the stuff in the/tmp Directory. other users cannot touch others, which is the role of the stuck bits. 3> How to set the preceding special permissions 3.1> chmod u + s xxx # set the setuid permission chmod g + s xxx # set the setgid permission chmod o + t xxx # set the stick bit permission, for directory 3.2> chmod 4775 xxx # set setuid permission chmod 2775 xxx # set setgid permission chmod 1775 xxx # set stick bit permission, for directory 4> Note: sometimes you set the s or t permission, and you will find that it becomes S or T, because at that location you did not grant it the x (executable) permission, in this case, the setting will not be effective. you can grant it the x permission first, and then grant the s or t permission.
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