linux 查看强制位,linux 文件特殊权限冒险位强制位粘制位

1:粘制位   sticky

对象:目录

作用:当一个目录上有t权限,那么目录中的文件只能被文件的拥有者删除

符号:o+t  t=1  1777

例子:

[root@localhost mnt]# mkdir dd

[root@localhost mnt]# touch dd/file

ll

-rw-r--r-- 1 root root 0 Jul 22 04:54 file1

[root@localhost mnt]# chmod 777 dd/file

[root@localhost mnt]# chmod 777 dd/[student@localhost mnt]$ rm -fr dd/file                       ##root新建用户,student可以删除

[root@localhost mnt]# chmod 1777 dd/                                                                                          ##给权限后

[root@localhost mnt]# touch dd/file1

[root@localhost mnt]# su student

[student@localhost mnt]$ rm -fr dd/file1

rm: cannot remove ‘dd/file1’: Operation not permitted                                                                   ##不能删除

2:冒险位       suid

对象:二进制可执行文件

作用:文件内记录的程序产生的进程的所有人为文件所有人

和进程发起人身份无关

设定方式:

chmod u+s file

suid=4

chmod 4xxx file

例子:

[root@localhost mnt]# which touch

/usr/bin/touch

[root@localhost mnt]# chown student /usr/bin/touch                           #把touch的所有人改为student

[root@localhost mnt]# ll /usr/bin/touch

-rwxr-xr-x. 1 student root 62432 Jan 24  2014 /usr/bin/touch

[root@localhost mnt]# touch file

[root@localhost mnt]# ll

total 0

-rw-r--r-- 1 root root 0 Jul 22 05:11 file                                                  #用root用户建立的文件所有人为root

[root@localhost mnt]# chmod 4777 /usr/bin/touch                             #给权限

[root@localhost mnt]# touch file2

[root@localhost mnt]# ll

total 0

-rw-r--r-- 1 root    root 0 Jul 22 05:11 file

-rw-r--r-- 1 student root 0 Jul 22 05:11 file2                                           #建立的文件为二进制文件所有人的

3:强制位  sgid

对象:文件/目录

作用:

文件:只针对二进制可执行文件,任何人运行二进制文件,程序时程序产生的进程的所有组都是文件的所有组,和程序发起人组的身份无关    此条和上述冒险位类似

目录:当当目录有sgid权限后,目录中新建的所有文件的所有组 都自动归属到目录的所有组之中,和文件建立者所在的组无关

设定方式:

chmod g+s file|dir

sgid=2

chmod 2xxx file|dir

例子:对于二进制文件

[student@localhost mnt]$ touch file1

[student@localhost mnt]$ ll

total 0

-rw-rw-r-- 1 student student 0 Jul 22 05:20 file1

[student@localhost mnt]$ exit

[root@localhost mnt]# chmod 2777 /usr/bin/touch

[root@localhost mnt]# su student

[student@localhost mnt]$ touch file2

[student@localhost mnt]$ ll

total 0

-rw-rw-r-- 1 student student0 Jul 22 05:20 file1

-rw-rw-r-- 1 student root    0 Jul 22 05:20 file2

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值