SUID, SGID, sticky位可以参考:
http://onlyzq.blog.51cto.com/1228/527247/
SUID属性只能运用在可执行文件上,当用户执行该执行文件时,会临时拥有该执行文件所有者的权限。
如果可执行文件所有者权限的第三位是一个小写的“s”就表明该执行文件拥有SUID属性。
[root@srv ~]# ll /usr/bin/passwd
-rwsr-xr-x 1 root root 22960 Jul 17 2006 /usr/bin/passwd
如果在浏览文件时,发现所有者权限的第三位是一个大写的“S”则表明该文件的SUID属性无效,比如将SUID属性给一个没有执行权限的文件。
Sticky属性
Sticky属性只能应用在目录,当目录拥有Sticky属性所有在该目录中的文件或子目录无论是什么权限只有文件或子目录所有者和root用户能删除。
配置SUID/SGID/Sticky属性
配置普通权限时可以使用字符或数字,SUID、SGID、Sticky也是一样。使用字符时s表示SUID和SGID、t表示Sticky;4表示SUID、2表示SGID、1表示Sticky。在配置这些属性时还是使用chmod命令。
当前目录目前情况。 [root@srv tmp]# ll total 52 drwxr-xr-x 2 root root 4096 Feb 15 22:47 test2 drwxr-xr-x 2 root root 4096 Feb 15 22:47 test3 drwxr-xr-x 2 root root 4096 Feb 15 22:46 test4 drwxr-xr-x 2 root root 4096 Feb 15 22:46 test5 -r-xr-xr-x 1 root root 5120 Feb 15 22:46 test6 -r-xr-xr-x 1 root root 3072 Feb 15 22:50 test7 drwxr-xr-x 2 root root 4096 Feb 15 22:56 test1 -r-xr-xr-x 1 root root 6144 Feb 15 22:48 test8 -r-xr-xr-x 1 root root 9216 Feb 15 22:51 test9 为文件test6增加SUID属性。 [root@srv tmp]# chmod u+s test6 l 为文件test8增加SUID属性。在使用数字表示时,原来的三位不变,只是增加了一个千位专门用于SUID、SGID、Sticky属性。下面的4就是SUID属性。 [root@srv tmp]# chmod 4555 test8 l 为目录test2增加SGID属性。 [root@srv tmp]# chmod g+s test2/ l 为目录test3增加SGID属性。 [root@srv tmp]# chmod 2755 test3/ l #为文件test7增加SUID和SGID属性,6=4(SUID)+2(SGID)。 [root@srv tmp]# chmod 6555 test7 l 为目录test4增加Sticky属性。 [root@srv tmp]# chmod o+t test4/ l 为目录test5增加Sticky属性。 [root@srv tmp]# chmod 1755 test5/ l 为目录test1增加SGID和Sticky属性,3=2(SGID)+1(Sticky)。 [root@srv tmp]# chmod 3755 test1/ l 执行上述更改命令后当前目录的情况。 [root@srv tmp]# ll total 52 drwxr-sr-x 2 root root 4096 Feb 15 22:47 test2 drwxr-sr-x 2 root root 4096 Feb 15 22:47 test3 drwxr-xr-t 2 root root 4096 Feb 15 22:46 test4 drwxr-xr-t 2 root root 4096 Feb 15 22:46 test5 -r-sr-xr-x 1 root root 5120 Feb 15 22:46 test6 -r-sr-sr-x 1 root root 3072 Feb 15 22:50 test7 drwxr-sr-t 2 root root 4096 Feb 15 22:56 test1 -r-sr-xr-x 1 root root 6144 Feb 15 22:48 test8 -r-xr-xr-x 1 root root 9216 Feb 15 22:51 test9 l 取消目录test1的SGID属性。 [root@srv tmp]# chmod g-s test1/ 在使用umask命令显示当前的权限掩码时,千位的“0”就是表示SUID、SGID、Sticky属性。 提示:在有些资料上SUID、SGID被翻译为“强制位”,Sticky被翻译为“冒险位”。