Linux目錄管理

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
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

友情鏈接更多精彩內(nèi)容