Linux文件特殊权限之SBIT-t

60 篇文章 0 订阅
54 篇文章 0 订阅
/*************************************************************************
 *****************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)
  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值