Linux----Suid\sgid

Source: Internet
Author: User

1, suid and Sgid are for the binary program, bash script is not its scope.

2, if a binary file is set to Suid, then when the UserA user executes it, it will be executed as the identity of the user who owns the file. Sgid;

3, Suid priority than Sgid, that is, if the two words set at the same time, and only set suid the same;

4, in general, a file belongs to the user's permissions than the permissions of the group is larger, so as long as set Sgid can solve the matter do not set suid.

Example:

1, take chown as an example to illustrate the role of SUID. Root/usra is a two different user

Root> cp/bin/chown/tmp/#把chown复制到/tmp/for testing.

root> touch/tmp/test.txt #创建一个test. txt file, because it is a touch that runs as root, the users and groups that belong to the file are root

Usra>/tmp/chown usra.usra/tmp/test.txt #usra用户想要修改test. txt files belong to users and groups that are prompted to have no permissions.

Root> chown u+s/tmp/test.txt #root用户为/tmp/chown added Suid.

Usra> chown Usra.usra/tmp/test.txt #成功

2, why say Suid,sgid just will be on binary file.

Root> Touch mybash.sh

Root> echo "Echo This is the content of mybash.sh" >/tmp/mybash.sh

root> chmod 744/tmp/mybash.sh The script in the #别以为这个usra用户就不能执行mybash. Sh

Usra> bash/tmp/mybash.sh #执行成功, no x permission is said that other can not be executed in/tmp/mybash.sh this way, not that the file can not be executed.

Linux----Suid\sgid

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.