特殊权限位:suid、sgid、sticky

别说谁变了你拦得住时间么 提交于 2019-11-27 12:41:17

 

linux系统特殊权限位 suid、sgid、sticky
suid 使任意用户获得用文件属主相同的权限,sgid使用户获得与文件属组相同的权限(通过sgid获得的权限等同于同一用户组的权限)
表示方法:
suid、sgid属于特殊权限位,位于基础权限位的x权限位置,s表示有x权限,S表示无x权限。
sticky属于特殊权限位,位于基础权限位的x权限位置,t表示有x权限,T表示无x权限。

[root@ 55test ts]# ll /usr/bin/passwd
-rwsr-xr-x. 1 root root 27832 Jun 10 2014 /usr/bin/passwd
[root@ 55test ts]# ll /etc/shadow
----------. 1 root root 904 Oct 10 23:39 /etc/shadow

  

设置suid、sgid方法:suid数字权限为4,sgid数字权限为2,sticky数字权限为1

chmod u+s a.sh      #添加suid
chmod u-s a.sh      #取消suid
chmod 4755 a.sh     #添加suid
chmod 0755 a.sh     #取消suid

chmod g+s a.sh      #添加sgid
chmod g-s a.sh      #取消sgid
chmod 2755 a.sh     #添加guid
chmod 0755 a.sh     #取消guid

chmod 6755 a.sh     #添加suid、sgid
chmod 0755 a.sh     #取消suid、guid


[root@ 55test mm3]# chmod 7755 3.txt     #添加suid、sgid、sticky
[root@ 55test mm3]# ll 3.txt 
-rwsr-sr-t. 1 root root 0 Jul 4 2019 3.txt
[root@ 55test mm3]# chmod a-x 3.txt      #取消ugo的x权限
[root@ 55test mm3]# ll 3.txt 
-rwSr-Sr-T. 1 root root 0 Jul 4 2019 3.txt
[root@ 55test mm3]# chmod u+x 3.txt      #添加用户x权限
[root@ 55test mm3]# ll 3.txt 
-rwsr-Sr-T. 1 root root 0 Jul 4 2019 3.txt

  

 

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!