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