/*************************************************************************
*****************Author: GouplovXim *******************************
*****************Date : 2018-01-29 16:05 *************************
*****************Description: 文件权限SBIT *************************
*************************************************************************/
引导:
案例
[goup@GouplovXim tom]$ ll -d /tmp
drwxrwxrwt. 3 root root 4096 1月 25 13:48 /tmp
SBIT(Stick Bit),粘滞位:
1.作用:
①只对目录有效
②普通用户对该目录有w和x权限
③若没有粘滞位,则普通用户可以对目录下的文件/子目录进行删除操作(因为普通用户对目录具有w权限),包括其它用户建立的目录/文件;但若赋了SBIT,
则普通用户只能删除自己创建的文件/目录,而不能删除不属于自己的文件/目录!
2.设置和取消SBIT
设置SBIT
chmod 1xxx < dir-name >
chmod o+t < dir-name >
取消SBIT
chmod xxx < dir-name >
chmod o-t < dir-name >
3.例程:
[goup@GouplovXim tmp]$ touch test-file
[goup@GouplovXim tmp]$ mkdir test-dir
[goup@GouplovXim tmp]$ ll
总用量 44
srwxrwxrwx 1 mysql mysql 0 1月 25 12:49 mysql.sock
-rw------- 1 daemon daemon 39890 1月 25 13:48 sess_vn4fkmempdoe4v20qps9sehrrf3itscg
drwxrwxr-x 2 goup goup 4096 1月 26 01:51 test-dir
-rw-rw-r-- 1 goup goup 0 1月 26 01:51 test-file
-rw-------. 1 root root 0 1月 24 00:20 yum.log
[goup@GouplovXim tmp]$ su tom -- 切换tom用户
密码:
[tom@GouplovXim tmp]$ rm -rf test-file -- tom无法删除
rm: 无法删除"test-file": 不允许的操作
[tom@GouplovXim tmp]$ rm -rf test-dir/
rm: 无法删除"test-dir": 不允许的操作
[tom@GouplovXim tmp]$ su -- 切换root
密码:
[root@GouplovXim tmp]# cd
[root@GouplovXim ~]# chmod o-t /tmp/ -- 取消粘滞位
[root@GouplovXim ~]# su tom
[tom@GouplovXim root]$ cd /tmp/
[tom@GouplovXim tmp]$ rm -rf a
[tom@GouplovXim tmp]$ rm -rf test-file -- tom删除成功
[tom@GouplovXim tmp]$ rm -rf test-dir/ -- tom删除成功
[tom@GouplovXim tmp]$ ls
mysql.sock sess_vn4fkmempdoe4v20qps9sehrrf3itscg yum.log
那么原来的执行标志x到哪里去了呢? 系统是这样规定的, 如果本来在该位上有x, 则这些特殊标志显示为小写字母 (s, s, t). 否则, 显示为大写字母 (S, S, T)
*****************Author: GouplovXim *******************************
*****************Date : 2018-01-29 16:05 *************************
*****************Description: 文件权限SBIT *************************
*************************************************************************/
引导:
案例
[goup@GouplovXim tom]$ ll -d /tmp
drwxrwxrwt. 3 root root 4096 1月 25 13:48 /tmp
SBIT(Stick Bit),粘滞位:
1.作用:
①只对目录有效
②普通用户对该目录有w和x权限
③若没有粘滞位,则普通用户可以对目录下的文件/子目录进行删除操作(因为普通用户对目录具有w权限),包括其它用户建立的目录/文件;但若赋了SBIT,
则普通用户只能删除自己创建的文件/目录,而不能删除不属于自己的文件/目录!
2.设置和取消SBIT
设置SBIT
chmod 1xxx < dir-name >
chmod o+t < dir-name >
取消SBIT
chmod xxx < dir-name >
chmod o-t < dir-name >
3.例程:
[goup@GouplovXim tmp]$ touch test-file
[goup@GouplovXim tmp]$ mkdir test-dir
[goup@GouplovXim tmp]$ ll
总用量 44
srwxrwxrwx 1 mysql mysql 0 1月 25 12:49 mysql.sock
-rw------- 1 daemon daemon 39890 1月 25 13:48 sess_vn4fkmempdoe4v20qps9sehrrf3itscg
drwxrwxr-x 2 goup goup 4096 1月 26 01:51 test-dir
-rw-rw-r-- 1 goup goup 0 1月 26 01:51 test-file
-rw-------. 1 root root 0 1月 24 00:20 yum.log
[goup@GouplovXim tmp]$ su tom -- 切换tom用户
密码:
[tom@GouplovXim tmp]$ rm -rf test-file -- tom无法删除
rm: 无法删除"test-file": 不允许的操作
[tom@GouplovXim tmp]$ rm -rf test-dir/
rm: 无法删除"test-dir": 不允许的操作
[tom@GouplovXim tmp]$ su -- 切换root
密码:
[root@GouplovXim tmp]# cd
[root@GouplovXim ~]# chmod o-t /tmp/ -- 取消粘滞位
[root@GouplovXim ~]# su tom
[tom@GouplovXim root]$ cd /tmp/
[tom@GouplovXim tmp]$ rm -rf a
[tom@GouplovXim tmp]$ rm -rf test-file -- tom删除成功
[tom@GouplovXim tmp]$ rm -rf test-dir/ -- tom删除成功
[tom@GouplovXim tmp]$ ls
mysql.sock sess_vn4fkmempdoe4v20qps9sehrrf3itscg yum.log
那么原来的执行标志x到哪里去了呢? 系统是这样规定的, 如果本来在该位上有x, 则这些特殊标志显示为小写字母 (s, s, t). 否则, 显示为大写字母 (S, S, T)