
linuxOPS基础_linux沾滞位T(sticky bit)
linux-dash
A beautiful web dashboard for Linux
项目地址:https://gitcode.com/gh_mirrors/li/linux-dash

·
命令:chmod
语法:# chmod [选项] 文件夹
作用:只允许文件的创建者和root用户删除文件
常用选项:o+t 添加粘滞位
o-t 去掉粘滞位
用法:chmod o+t 目录名
示例代码:
#chmod o+t
含义:给目录增加粘滞位权限。
举例:
公司多个部门公用一个文件夹work,为了让所有人都能访问,work文件夹赋予了777权限,用户root新建了一个文件root.txt,发现被别人删除了。我们希望root建立的文件,只有root自己可以删。
步骤1:root用户下操作
root用户新建文件夹/work,并且新建两个文件root.txt和root1.txt,赋予/work文件夹和下面的文件777权限
#mkdir /work
#cd /work
#touch root.txt
#touch root1.txt
#chmod -R 777 /work
#ll -d /work
步骤2: wangwu用户下操作
在没有设置粘滞位的时候,wangwu可以删除root创建的文件。
cd /work
ll -d /work
ll
rm -rf root.txt
ll
步骤3:root用户下操作:
给/work文件夹添加粘滞位
#ll -d /work/
#chmod o+t /work
#ll -d /work/

步骤4:wangwu用户下操作
发现添加粘滞位后,无法删除root2.txt文件
#ll -d /work/
#chmod o+t /work
#ll -d /work/
步骤5:root用户下操作
去掉/work文件夹的取消粘滞位
#ll -d /work/
#chmod o-t /work
#ll -d /work/
步骤6:wangwu用户下操作
wangwu用户下,发现又可以删除了
#cd /work/
#rm -rf root1.txt
#ll




A beautiful web dashboard for Linux
最近提交(Master分支:5 个月前 )
186a802e
added ecosystem file for PM2 4 年前
5def40a3
Add host customization support for the NodeJS version 4 年前
更多推荐
所有评论(0)