Linux-(12) special permissions, linux-12 Permissions
In the previous article, we talked about basic permission management in Linux. umask has three digits. However, when we run the umask command to view the umask value of the current user, we found that the output is four digits, the extra one is special permissions.
There are also three types of special permissions: suid, sgid, and sticky. The meanings of these three permissions are as follows:
Suid: Execute the file as the user to which the file belongs, instead of the current user. This does not affect the directory. this means that there is an executable file a, which belongs to user a, and user a has the x (execution) permission on it, and user B belongs to o (other). In this case, user a can execute a, while user B cannot execute. however, after the suid permission is granted to file a, user B can execute file a because it is not executed as user a but as user.
Sgid: similar to suid, which is for the group. an object is run as the object group. for the directory, sgid indicates that the group of any files created under the directory is the same as that of the directory.
Sticky: The sticky permission allows users with write permission on directories to delete only files they own and Files Owned by other users. this is also clear, that is, a shared directory, users can only delete their own files, cannot delete other people's files.
Set special permissions:
Still using the chmod command
Set suid: chmod u + s file
After the file is set, the File Permission changes. The file permission before suid is set as follows:
-Rwxr -- r -- 1 root 5 April 27 16:02 aaa *
After chmod u + s aaa is executed, the File Permission becomes as follows:
-Rwsr -- r -- 1 root 5 April 27 16:02 aaa *
X is changed to s.
Set sgid: chmod g + s file
After setting, the x-bit of the group is changed to s.
-Rwsr-Sr -- 1 root 5 April 27 16:02 aaa *
Set sticky: chmod o + t file
After setting, the last bit is t
Drwxr-xr-t 2 root 4096 April 27 16:10 bbb/
Similar to common permissions, special permissions can also be expressed in numbers.
Suid = 4 (2 square)
Sgid = 2 (1 power of 2)
Sticky = 1 (0 power of 2)
Example: chmod 4755 file
Reprinted please indicate the source
Http://blog.csdn.net/redstarofsleep/article/details/45311387