Linux setuid and setgid explain

  
                  

Create a new group family as a public group

groupadd family

Create two new users shuai hongyan password settings

useradd shaui

useradd hongyan< Br>

passwd shuai

passwd hongyan

Add these two users to these two groups

usermod -G family shuai

Usrmod -G family hongyan

Create a new directory in the current directory share

mkdir share

Assign the owning group of this directory to family

chown : Family share

Viewing the permissions of the share

ll -d share

Trying to use shuai can write

cd share

Touch shuai.a

ll shuai.a View the file whose group is still shuai

and then set it to setgid

chmod g+s share

We assign the owner of the directory to the family group

chown :family share

and set the w write permission for it to allow the users in the group to write to Build an environment

chmod g+w share

Without specifying setgid

Let shuai users go in and create a file to see the group

touch shuai.b

ll shuai.b

Let hongyan users go in and delete it

rm shuai.b

can be deleted < Br>

Then we build sticky bit permission for share

chmod o+t share

Switch to shuai user

We will find that although there is setgid already I can't delete the files that are hot.

Then set the gid and let them go to the settings file to see the group

and then delete it

Finally we set this file. Stickty bit

Then use the shuai user to delete the hongyan user's file and it will prompt an error.

Copyright © Windows knowledge All Rights Reserved