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

来源:互联网 发布:java 线程池 参数 编辑:程序博客网 时间:2024/05/01 15:38

    最近,项目对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]$ 


0 0