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