Three more special permissions for Linux

Source: Internet
Author: User

Linux also has three more special permissions, namely:setuid,setgid,stick bit .

-: Indicates generic file

D: Represents a catalog file

L: Indicates a linked file

B: Represents a block device

C: Indicates a character device

P: Indicates pipeline

S: Indicates socket

1.setuid,setgid:

The role of setuid is to allow the user executing the command to execute with the permission of the owner of the command , that is, the normal user will have root permission to execute passwd, so that the/etc/passwd file can be modified. It is marked as: S, where it appears in X, for example:-rwsr-xr-x. The setgid means that the user executing the file is executed with the permission of the group to which the file belongs.

2.stick bit:

we know that/tmp is the temporary file directory of the system, all users in the directory has all the permissions, that is, in this directory can be arbitrarily created, modify, delete files, if user A in the directory created a file, User B deleted the file, We cannot allow this situation. To achieve this, the concept of stick bit (sticky bit) is present. it (stick bit) is for the directory, if the directory is set stick bit (sticky bit), the directory of files in addition to the creator and root of the file can delete and modify the stuff in the/tmp directory, other users cannot move others, This is the role of sticky bits.

3, how to set special permissions to files:

chmod u+s XXX # set setuid permissions

chmod g+s XXX # set Setgid permissions

chmod o+t XXX # set stick bit permissions for directory

chmod 4775 XXX # set setuid permissions

chmod 2775 XXX # set Setgid permissions

chmod 1775 XXX # set stick bit permissions for directory

Note: Sometimes you set the s or T permission, you will find it becomes s or T, this is because in that position you do not give it X (executable) permissions, so that the setting is not valid, you can first give it an X permission, and then give S or T permissions.

Three more special permissions for Linux

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.