setuid、setgid及粘贴位

setuid、setgid及粘贴位
提示:生产场景用的不多,了解即可。
作用让不同用户可以以root用户运行只有root账号运行的程序。
形象的例子代天子牧守四方,大臣拿尚方宝剑。
[root@model ~]# ls -l /etc/passwd
-rw-r--r--. 1 root root 1623 Jan  7 16:30 /etc/passwd
例子:root@model ~]# ls -l /usr/bin/passwd 
-rwsr-xr-x. 1 root root 30768 Feb 22  2012 /usr/bin/passwd
看到这个s了吗,普通用户能够修改自己的密码的原因就是普通执行passwd命令时临时获得了root权限。


setuid在权限之前加一个数字,4000。setgid则是在权限之前加一个数字2000。
[root@model ~]# chmod 4744 testfile 
[root@model ~]# ll testfile 
-rwsr--r-- 1 root root 0 Jan  7 20:47 testfile
[root@model ~]# chmod 2744 testfile 
[root@model ~]# ll testfile 
-rwxr-Sr-- 1 root root 0 Jan  7 20:47 testfile
注意:s为本来的权限本身有x即可执行权限。S为权限本身没有可执行权限-。


粘贴位
作用:即使这个文件的权限是777,但是其他用户没有权限删除这个文件,只有属主才可以删除它。
drwxrwxrwt. 4 root root 4096 Jan  7 21:13 /tmp
[root@model ~]# chmod 1744 testfile 
[root@model ~]# ll testfile 
-rwxr--r-T 1 root root 0 Jan  7 20:47 testfile
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值