• linux系统中SBIT权限


    1、linux中SBIT权限用于对目录进行设定

    使只有文件或者目录的所有者才能删除文件或者目录

    测试不加 SBIT权限的情况:

    [root@linuxprobe home]# mkdir test01 test02
    [root@linuxprobe home]# chmod 777 test01  ## 对test01赋予最高权限
    [root@linuxprobe home]# su - linuxprobe  ## 切换至普通目录
    Last login: Tue Oct 20 17:10:42 CST 2020 from 192.168.3.4 on pts/1
    [linuxprobe@linuxprobe ~]$ cd /home/test01
    [linuxprobe@linuxprobe test01]$ ls
    [linuxprobe@linuxprobe test01]$ whoami
    linuxprobe
    [linuxprobe@linuxprobe test01]$ touch file01  ## 创建普通文件
    [linuxprobe@linuxprobe test01]$ chmod 777 file01 ## 赋予最高权限
    [linuxprobe@linuxprobe test01]$ su - liujiaxin01  ## 切换至另一普通用户
    Password:
    Last login: Tue Oct 20 21:42:38 CST 2020 on pts/0
    [liujiaxin01@linuxprobe ~]$ cd /home/test01
    [liujiaxin01@linuxprobe test01]$ ls
    file01
    [liujiaxin01@linuxprobe test01]$ ll
    total 0
    -rwxrwxrwx. 1 linuxprobe linuxprobe 0 Oct 20 22:20 file01
    [liujiaxin01@linuxprobe test01]$ rm -f file01  ## 可以顺利删除

    2、测试添加SBIT权限情况

    [root@linuxprobe home]# whoami
    root
    [root@linuxprobe home]# chmod 777 test02
    [root@linuxprobe home]# chmod o+t test02 ## 添加SBIT权限
    [root@linuxprobe home]# su - linuxprobe  
    Last login: Tue Oct 20 22:27:57 CST 2020 on pts/0
    [linuxprobe@linuxprobe ~]$ cd /home/test02/
    [linuxprobe@linuxprobe test02]$ touch file02
    [linuxprobe@linuxprobe test02]$ chmod 777 file02
    [linuxprobe@linuxprobe test02]$ ll
    total 0
    -rwxrwxrwx. 1 linuxprobe linuxprobe 0 Oct 20 22:29 file02
    [linuxprobe@linuxprobe test02]$ su - liujiaxin01  ## 切换至另一普通用户
    Password:
    Last login: Tue Oct 20 22:21:18 CST 2020 on pts/0
    [liujiaxin01@linuxprobe ~]$ cd /home/test02
    [liujiaxin01@linuxprobe test02]$ ll
    total 0
    -rwxrwxrwx. 1 linuxprobe linuxprobe 0 Oct 20 22:29 file02
    [liujiaxin01@linuxprobe test02]$ whoami
    liujiaxin01
    [liujiaxin01@linuxprobe test02]$ rm -f file02   ## 因为设置了SBIT权限,即便权限充足,也不能删除
    rm: cannot remove ‘file02’: Operation not permitted

    3、SBIT权限标志及设置方法

    [liujiaxin01@linuxprobe home]$ pwd
    /home
    [liujiaxin01@linuxprobe home]$ ll
    total 8
    drwx------. 14 linuxprobe  linuxprobe  4096 Oct 20 17:14 linuxprobe
    drwx------.  5 liujiaxin01 liujiaxin01 4096 Oct 20 21:29 liujiaxin01
    drwxr-xr-x.  4 root        root          76 Oct 20 13:58 software
    drwxrwxrwx.  2 root        root           6 Oct 20 22:21 test01
    drwxrwxrwt.  2 root        root          19 Oct 20 22:28 test02  ## test02目录具有SBIT权限,在其他人权限的执行位置上是t,而不是x

    设置方法:

    [root@linuxprobe home]# whoami
    root
    [root@linuxprobe home]# chmod o+t test01  ## 添加SBIT权限
    [root@linuxprobe home]# ll
    total 8
    drwx------. 14 linuxprobe  linuxprobe  4096 Oct 20 17:14 linuxprobe
    drwx------.  5 liujiaxin01 liujiaxin01 4096 Oct 20 21:29 liujiaxin01
    drwxr-xr-x.  4 root        root          76 Oct 20 13:58 software
    drwxrwxrwt.  2 root        root           6 Oct 20 22:21 test01
    drwxrwxrwt.  2 root        root          19 Oct 20 22:28 test02

    注:SBIT权限实现在特定目录下仅所有者才能删除文件
  • 相关阅读:
    Oracle 11g R2性能优化 SQL TRACE
    Oracle 11g R2创建数据库之手工建库方式
    Oracle 11g R2创建数据库之DBCA静默方式
    CentOS 7静默安装Oracle 11g R2数据库软件
    如何在Windows上使用Git创建一个可执行脚本?
    我们为什么推荐在Json中使用string表示Number属性值?
    [麻雀虽小,五脏俱全] 之网站重写之路
    2020年必须掌握的硬核技能k8s
    [半翻] 设计面向DDD的微服务
    Quartz.net在集群环境下的 部署任务的姿势
  • 原文地址:https://www.cnblogs.com/liujiaxin2018/p/13849602.html
Copyright © 2020-2023  润新知