Linux 权限管理之目录权限限制

    最近,项目对Linux文件目录有要求:业务用户及其启动进程能对指定目录drwx,其中有一个用户对该业务用户的目录中的一个子目录能够rwx,

但是对该子目录以上的其他目录不能进行读写操作。其实实现很简单,假设root是业务用户,test是受限用户,/test/t1是root的业务目录,/test/t1/t2

是test用户能够访问并进行操作的受限目录,那么只需要给/test一个701,给t1一个701,给/test/t1/t2一个700并将t2的属组及宿主改为test:test就能

保证root能对/test下任何文件及目录的绝对操作权限又能把test用户限制在/test/t1/t2中,test用户不能对/test或/test/t1进行读写操作。

    示例如下:

[root@oratest /]# ls -l
total 192
...
drwx-----x   3 root   root      4096 Apr 26 17:21 test
...
[root@oratest /]# 

[root@oratest test]# ls -l
total 4
drwx-----x 3 root root 4096 Apr 26 17:21 t1
[root@oratest test]# 

[root@oratest t1]# ls -l
total 4
-rw-r--r-- 1 root root    0 Apr 26 17:21 t
drwx------ 2 test test 4096 Apr 27 09:30 t2
[root@oratest t1]# 

[test@oratest ~]$ cd /test
[test@oratest test]$ ls
ls: .: Permission denied
[test@oratest test]$ cd t1
[test@oratest t1]$ ls
ls: .: Permission denied
[test@oratest t1]$ cd t2
[test@oratest t2]$ ls
1  b
[test@oratest t2]$ touch a
[test@oratest t2]$ ls
1  a  b
[test@oratest t2]$ 


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值