Linux嵌套目录权限的比较探究

在/tmp目录下新建一个嵌套目录,名字分别为test_0、test_1、test_2。在test_2目录下新建普通文件,名为tryme。设置test_0和test_2的权限为777,设置test_1的权限为700,tryme文件的权限为777,问tryme这个文件能否被读取?

1 cd /tmp
2 mkdir -p test_0/test_1/test_2
3 touch test_0/test_1/test_2/tryme
4 chmod 777 test_0/
5 cd test_0
6 chmod 700 ./test_1/; chmod 777 ./test_1/test_2/; chmod 777 ./test_1/test_2/tryme
[linuxprobe@linuxprobe test_0]$ ll -d; ll -R
drwxrwxrwx. 3 linuxprobe linuxprobe 19 Apr 27 10:55 .
.:
total 0
drwx------. 3 linuxprobe linuxprobe 19 Apr 27 10:55 test_1

./test_1:
total 0
drwxrwxrwx. 2 linuxprobe linuxprobe 18 Apr 27 10:56 test_2

./test_1/test_2:
total 0
-rwxrwxrwx. 1 linuxprobe linuxprobe 0 Apr 27 10:56 tryme
$ su - zhangsan
Password:
Last login: Wed Apr 27 08:46:08 CST 2022 on tty3
[zhangsan@linuxprobe ~]$ cat /tmp/test_0/test_1/test_2/tryme
cat: /tmp/test_0/test_1/test_2/tryme: Permission denied

答案是不能,因为目录的权限是一层层读取的,嵌套目录中只要有一层目录的权限设置不正确,就会影响下级目录和文件。

如果把目录test_1的权限设置为701,tryme能否读取呢?(事先已经用linuxprobe用户编辑好了一段话:This is a message from user ‘linuxprobe’

1 [zhangsan@linuxprobe ~]$ su - linuxprobe
 2 Password:
 3 Last login: Wed Apr 27 10:52:32 CST 2022 on :0
 4 [linuxprobe@linuxprobe ~]$ cd /tmp/test_0/
 5 [linuxprobe@linuxprobe test_0]$ chmod 701 test_1/
 6 [linuxprobe@linuxprobe Desktop]$ su - zhangsan
 7 Password:
 8 Last login: Wed Apr 27 11:18:50 CST 2022 on pts/0
 9 [zhangsan@linuxprobe ~]$ cd /tmp
10 [zhangsan@linuxprobe tmp]$ cat test_0/test_1/test_2/tryme
11 This is a message from user 'linuxprobe'.

总结:在嵌套目录中,各上层目录有x权限的情况下,就可以对最底层的文件做出cp cat等命令。

Original: https://www.cnblogs.com/randyszone/p/16198255.html
Author: randy198
Title: Linux嵌套目录权限的比较探究

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/583094/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

  • 《Redis开发与运维》——(八)理解内存(脑图)

    posted @2021-01-09 15:08 雪山上的蒲公英 阅读(122 ) 评论() 编辑 / 返回顶部代码 / Original: https://www.cnblogs…

    Linux 2023年5月28日
    090
  • 斐波那契数列前1000项

    斐波那契数列前1000项 {1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,1597,2584,4181,6765,10946,177…

    Linux 2023年6月6日
    079
  • centos 安装bochs

    下载地址 https://sourceforge.net/projects/bochs/files/bochs/ 我这里安装2.6.2 tar xvfz bochs-2.6.2.t…

    Linux 2023年6月7日
    083
  • 安卓逆向从0到1学习总结

    PS:该文已经首发于公众号信安之路!!! 初识安卓逆向是在2019年的暑假,到现在也快一年了,这一年来有刚从web渗透转来的迷茫,有成功破解了第一个app的喜悦,也有通宵熬夜逆向的…

    Linux 2023年6月8日
    0110
  • PyTorch介绍-使用 TORCH.AUTOGRAD 自动微分

    训练神经网络时,最常用的算法就是 反向传播。在该算法中,参数(模型权重)会根据损失函数关于对应参数的梯度进行调整。 为了计算这些梯度,PyTorch内置了名为 torch.auto…

    Linux 2023年6月14日
    0101
  • TCP传输层协议 特性

    客户A和服务器B都处于建立连接的状态,此时客户A主动与服务器B发出断开连接的请求: 第一步:客户A会发送一个序号为Seq=u的报文给服务器B,此时控制位中的断开位FIN=1,即请求…

    Linux 2023年6月6日
    078
  • [极客大挑战 2019]Secret File

    0x01 寻找做题信息 打开环境,查看源代码,发现可疑链接,/Archive_room.php,action.php打开action.php会发生302跳转,查找302跳转无果,百…

    Linux 2023年6月8日
    085
  • Vue3

    setup 函数时,它将接受两个参数:(props、context(包含attrs、slots、emit)) setup函数是处于 生命周期函数 beforeCreate 和 Cr…

    Linux 2023年6月13日
    080
  • WEB自动化-04-Cypress 测试用例编写和组织

    4 测试用例编写和组织 4.1 用例结构 Cypress是建立在 Mocha和 Chai之上,因此同时支持Chai的 BDD和 TDD两种风格。如果你熟悉JavaScript风格的…

    Linux 2023年6月7日
    0102
  • windows server实现AD域对接

    安装两台windows server虚拟机 选择自定义 默认兼容 选择2012镜像 输入密钥 名字位置自己选择 默认 选择4个处理器 内存4G够用 选择仅主机网络 默认 创建磁盘 …

    Linux 2023年6月8日
    083
  • redis服务器

    这一次主要讲下redis中服务器这个结构体相关代码,主要从是代码层面进行讲解 redis服务器 redis服务器结构体主要代码在 redis.h/redisServer,下面给出该…

    Linux 2023年6月13日
    083
  • docker相关命令杂理

    – 2020.11.16docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]] #保存现有的镜像 # docker commit …

    Linux 2023年6月8日
    079
  • Shell 实现多线程(多任务)

    1.命令结尾添加:& 在命令的末尾加 & 符号,则命令将在后台执行,这样后面的命令不需要等待该命令执行完再开始执行。 2.解决主线程提前退出问题,添加 wait 3…

    Linux 2023年5月28日
    081
  • Java语言高级(第六部分)函数式接口 Stream流、方法引用 ->(个人学习记录笔记)

    第一章 函数式接口 1.1 概念 函数式接口在Java中是指: 有且仅有一个抽象方法的接口。 函数式接口,即适用于函数式编程场景的接口。而Java中的函数式编程体现就是Lambda…

    Linux 2023年6月8日
    077
  • php连接mysql数据库大批量执行sql语句出现“Mysql server has gong away”错误

    php代码中加入以下代码 set_time_limit(3600); ini_set(‘memory_limit’, ‘1024M’); mysql客户端执行以下命令 set gl…

    Linux 2023年6月13日
    079
  • debian与windows时间不同步的简单治疗方法

    试过几种方法, 但就这个方法好使点。hwclock -w –localtime Original: https://www.cnblogs.com/leotiger/p…

    Linux 2023年6月13日
    068
亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球