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 ~]#