Linux权限管理之目录权限限制的示例分析

38次阅读
没有评论

共计 1067 个字符,预计需要花费 3 分钟才能阅读完成。

这篇文章主要为大家展示了“Linux 权限管理之目录权限限制的示例分析”,内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让丸趣 TV 小编带领大家一起研究并学习一下“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]$ 

以上是“Linux 权限管理之目录权限限制的示例分析”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注丸趣 TV 行业资讯频道!

正文完
 
丸趣
版权声明:本站原创文章,由 丸趣 2023-08-25发表,共计1067字。
转载说明:除特殊说明外本站除技术相关以外文章皆由网络搜集发布,转载请注明出处。
评论(没有评论)