1、實(shí)驗(yàn)- u+s
su - uos1
vim /etc/passwd
我們直接在普通用戶使用vim編輯器打開(kāi)文件是不可以修改的
chmod u+s /usr/bin/vim
su - uos1
vim /etc/passwd
#######這個(gè)時(shí)候給vim設(shè)置強(qiáng)制位setuid之后就可以以root身份去執(zhí)行
2、實(shí)驗(yàn)-g+s
groupadd haha
創(chuàng)建組haha
mkdir /uos
創(chuàng)建目錄/uos 并設(shè)置所屬組為haha
chown :haha /uos/
ll -d /uos/
drwxr-xr-x 2 root haha 4096 3月 26 14:17 /uos/
touch /uos/1.txt
新創(chuàng)建文件、可以看到其屬組還是屬于船建者的
ll /uos/1.txt
-rw-r--r-- 1 root root 0 3月 26 14:19 /uos/1.txt
chmod g+s /uos/
為屬組添加強(qiáng)制位setgid
touch /uos/2.txt
可以看到新建的文件會(huì)自動(dòng)繼承此前目錄的屬組
ll /uos/2.txt
-rw-r--r-- 1 root haha 0 3月 26 14:20 /uos/2.txt
3、實(shí)驗(yàn)-o+t
useradd -m -s /bin/bash hehe
useradd -m -s /bin/bash lele
mkdir /tongx
chmod o=rwx /tongx/
su - hehe
touch /tongx/hehe1
注銷
rm /tongx/hehe1
是可以刪除的
注銷
chmod o+t /tongx/
su - hehe
touch /tongx/lele
注銷
su - lele
rm -rf /tongx/lele
rm: 無(wú)法刪除'/tongx/lele': 不允許的操作
加上t權(quán)限之后就不可以刪除其他人的文件
4、實(shí)驗(yàn)-umask
umask
0022
當(dāng)前umask掩碼是0022,新創(chuàng)建文件的權(quán)限是644,目錄的權(quán)限是755
touch file1
mkdir di1
ll file1
-rw-r--r-- 1 root root 0 3月 26 15:39 file1
ll di1/ -d
drwxr-xr-x 2 root root 4096 3月 26 15:39 di1/
umask 0027
######將umask掩碼修改為0027之后,新建文件的權(quán)限是640,目錄的權(quán)限是750
touch file2
mkdir di2
ll file2
-rw-r----- 1 root root 0 3月 26 16:08 file2
ll -d di2
drwxr-x--- 2 root root 4096 3月 26 16:08 di2