linux-(12) Special permissions

Source: Internet
Author: User

The previous article is about Linux basic Rights management, which says that Umask has three digits, but when we execute the umask command to view the current user's umask value, we find that the output is 4 bits, which is the special permission.

Special permissions are also divided into 3 categories, namely suid,sgid,sticky. The meanings of these three kinds of permissions are:

SUID: Executes the file as the file's owning user, not the current user, and has no effect on the directory. This means that there is an executable file a, which belongs to the user A, and the User A has X (execute) permission, User B belongs to O (other), this way, user A can be executed a, The User B cannot execute a. However, when the SUID permission is given to file A, the user B can execute the file a, because he does not execute it in his own identity, but executes it as user A.

Sgid: Similar to suid, this is for groups. The file is run as the group that the file belongs to. For a directory, sgid means that the owning group of any file created under that directory is the same as the owning group for that directory.

Sticky:sticky permissions allow users who have write access to the directory to delete only the files they own and cannot delete files owned by other users. This is also relatively clear, that is, a shared directory, the user can only delete their own files, can not delete other people's files.


To set special permissions:

Still using the chmod command

Set Suid:chmod u+s file

The permissions of the file after it has been set will change, and the permissions for the file before setting Suid are:

-rwxr--r--  1 root root    5  April 16:02 aaa*
After chmod u+s AAA is executed, the permissions of the file become:
-rwsr--r--  1 root root    5  April 16:02 aaa*
X is turned into S.

Set Sgid:chmod g+s file

After the same setup, the group's X-bits become s

-rwsr-sr--  1 root root    5  April 16:02 aaa*
Set Sticky:chmod o+t file
Once set, the last one becomes T
Drwxr-xr-t  2 root root 4096  April 16:10 bbb/

As with normal permissions, special permissions can also be represented in a digital way

Suid=4 (square of 2)

sgid=2 (2 of 1 parties)

Sticky=1 (2 of 0 Parties)

Example: chmod 4755 file


Reprint please indicate the source

Http://blog.csdn.net/redstarofsleep

linux-(12) Special permissions

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.