运维大法之Linux系统中的管理权限(三)特殊权限
特殊权限
stickyid 粘制位
针对目录: 如果一个目录stickyid开启,那么这个目录中的文件只能被文件所有人删除
chmod 1原始权限 dir
chmod o+t dir
实验:
mkdir /pub
chmod 777 /pub
su - westos ----> touch /pub/westosfile
exit
su - han --------> touch /pub/hanfile
rm -fr /pub/hanfile 可以删除
rm -fr /pub/westosfile 不属于自己的文件也可以删除
如何解决此问题:
chmod 1777 /pub
chmod o+t /pub
以上两条命令都可以开启pub目录的t权限
su - westos ----> touch /pub/westosfile
exit
su - han --------> touch /pub/hanfile
rm -fr /pub/hanfile 可以删除
rm -fr /pub/westosfile 不属于自己的文件不能删除
rm: cannot remove ‘westosfile’: Operation not permitted
sgid 强制位
针对目录: 目录中新建的文件自动归属到目录的所属组中
设定:
chmod 2源文件权限 dir
chmod g+s dir
示例为强制位的影响:*只针对二进制的可执行文件(c程序) 当运行二进制可执行文件时都是用文件拥有组身份运行,和执行用户无关**实验
suid 冒险位
只针对二进制的可执行文件(c程序) 当运行二进制可执行文件时都是用文件拥有者身份运行,和执行用户无关
chmod 4原属性 file
chmod u+s file
示例:只针对二进制的可执行文件(c程序) 当运行二进制可执行文件时都是用文件拥有者身份运行,和执行用户无关
第二周的知识总结完毕,练就完了!溜了溜了!