SUID, SGID, and Sticky attributes of the file

Source: Internet
Author: User

SUID, SGID, and Sticky attributes of the file

SUID attributes
The SUID attribute is generally used on an executable file. When a user executes the file, the user temporarily has the permission of the owner of the executable file. When you use the "ls-l" or "ll" command to browse a file, if the third digit of the executable file owner permission is a lowercase "s ", it indicates that the execution file has the SUID attribute. For example, the/usr/bin/passwd file.

$ Ll/usr/bin/passwd-rwsr-xr-x 1 root 41284 April 9 2012/usr/bin/passwd

SGID attributes
When the SGID attribute is applied to a directory, the owner Group of the files or subdirectories created in the directory will be the owner Group of the directory. When the SGID attribute is applied to an executable file, other users temporarily have group permissions for the executable file when using the file. When you use the "ls-l" or "ll" command to browse a directory, if the third digit with group permissions is a lowercase "s ", it indicates that the execution file or directory has the SGID attribute.

Sticky Bit attribute
The Sticky attribute can only be applied to the directory. When the directory has the Sticky attribute, only the owner of the file or sub-directory and the root user can delete all files or sub-directories in the directory regardless of the permission. When you use the "ls-l" or "ll" command to browse the directory, if the third digit of other user permissions is a lowercase "t ", it indicates that the execution file or directory has the Sticky attribute.

Note: The linux system requires that, if there is x on this digit, these attributes are displayed with lowercase letters (valid); otherwise, uppercase letters (invalid) are displayed)

Configure the SUID, SGID, and Sticky attributes

Character configuration can be used (s represents SUID and SGID, t represents Sticky)
For example:

Chmod u + s test_file # Add the SUID attribute chmod g + s test_dir to the file # Add the SGID attribute chmod o + t test_dir # Add the Sticky attribute to the directory

You can also configure it using numbers (4 indicates SUID, 2 indicates SGID, and 1 indicates Sticky)
For example:

Chmod 4555 test_file # Add the SUID attribute chmod 2555 test_file # Add the SGID attribute chmod 1555 test_dir # Add the Sticky attribute to the file

Related Article

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.