特殊权限位:suid、sgid、sticky

 

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

  

 

posted on 2019-08-16 13:40  00花匠  阅读(328)  评论(0编辑  收藏  举报

导航