Title: setuid and setgid. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
Create a new family as a public group
Groupadd family
Create two user shuai hongyan password settings
Useradd shaui
Useradd hongyan
Passwd shuai
Passwd hongyan
Add these two users to the two groups
Usermod-G family shuai
Usrmod-G family hongyan
Create a directory share under the current directory
Mkdir share
Specify the owner group of this directory to family.
Chown: family share
View share Permissions
Ll-d share
Use shuai to try writing
Cd share
Touch shuai.
Ll shuai. a. Check that the group to which the file belongs is still shuai.
Then set it to setgid.
Chmod g + s share
We specify the directory owner to the family group.
Chown: family share
And set w write permission for it to allow users in the group to write permission to create an environment for the experiment
Chmod g + w share
If setgid is not specified
Let shuai users establish a file production view group
Touch shuai. B
Ll shuai. B
Let the hongyan user go in and delete it.
Rm shuai. B
Yes.
Then we create the stickty bit permission for share.
Chmod o + t share
Switch to shuai user
We will find that even if there is a setgid, it is no longer possible to delete other hot files.
Then set the gid so that they can go in and set the file to view the group.
Then it can be deleted.
Finally, we set stickty bit for this file.
Then, the shuai user is used to delete the hongyan user's file and an error is prompted.