S UID SGID SOID 核心就在 “S” ,S就是允许本圈子 用户有r,w,x ;
例如:1、chmod s+g test.txt 只允许testex.txt所在的组 员可以执行r,w,x
2、chmod u+s test.txt2 只允许test.txt2的属主 执行r,w,x
温馨提示:对SUID只需要有个了解就行了,不要瞎设置,否则会影响系统的稳定运行
1、临时提权让不同的组之间可以相互查看别创建的文件
[root@localhost ~]# chmod u+s /usr/bin/cat 注:把cat放到/usr/bin/才会运行
[root@localhost ~]# ll /usr/bin/cat
-rwsr-xr-x. 1 root root 54080 11月 6 2016 /usr/bin/cat
[root@localhost ~]#
2、将赋予的SUID临时提权给去掉
[root@localhost ~]# chmod u-s /usr/bin/cat
[root@localhost ~]# ll /usr/bin/cat
-rwxr-xr-x. 1 root root 54080 11月 6 2016 /usr/bin/cat
[root@localhost ~]#
3、举个鲜明的例子,passwd天生就具有SUID,能使普通用户自己可改密码;
[peng1@localhost ~]$ ll /usr/bin/passwd
-rwsr-xr-x. 1 root root 27832 6月 10 2014 /usr/bin/passwd
[peng1@localhost ~]$
关于SGID,说白了设置SGID相当于给hr目录设置权限继承关系,
[root@localhost ~]# mkdir /home/hr
[root@localhost ~]# ll /home/hr
总用量 0
[root@localhost ~]# ll -d /home/hr
drwxr-xr-x. 2 root root 6 4月 19 14:00 /home/hr
[root@localhost ~]# chmod g+s /home/hr
[root@localhost ~]# ll -d /home/hr
drwxr-sr-x. 2 root root 6 4月 19 14:00 /home/hr
[root@localhost ~]#
3、stiky:保证在公共环境里只有自己能del其他用户不能del
[root@localhost ~]# mkdir /home/hr2
[root@localhost ~]# chmod 777 /home/hr2
[root@localhost ~]# chmod o+t /home/hr2
[root@localhost ~]# ll -d /home/hr2
drwxrwxrwt. 2 root root 6 4月 19 15:23 /home/hr2
[root@localhost ~]#