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等命令。
Linux嵌套目录权限的比较探究的更多相关文章
- 从零单排Linux – 2 – 目录权限
从零单排Linux – 2 – 目录权限 1.sync 讲内存数据跟新到硬盘中 2.执行等级init a: run level 0:关机 b: run level 3:纯命令模式 c:run leve ...
- Linux文件/目录权限设置命令:chmod
文件/目录权限设置命令:chmod 这是Linux系统管理员最常用到的命令之一,它用于改变文件或目录的访问权限.该命令有两种用法: 用包含字母和操作符表达式的文字设定法 其语法格式为:chmod [w ...
- linux 网站目录权限设置
Linux下Apache网站目录读写权限的设置 网站目录文件权限的设置对网站的安全至关重要,下面简单介绍网站目录文件权限的基本设定. 我们假设http服务器运行的用户和用户组是www,网站用户为cen ...
- 【Linux】目录权限与文件权限
现在我们知道了Linux系统内文件的三种身份(拥有者.群组与其他人),知道每种身份都有三种权限(rwx),已知道能够使用chown, chgrp, chmod去修改这些权限与属性,当然,利用ls -l ...
- linux改目录权限和宿主。
改宿主. [sudo chown 用户名:用户组 ./目录/*] 改权限 [ sudo chmod -R 775 ./目录]
- Linux文件/目录权限整理
- Linux文件和目录权限详细讲解
转载请标明出处: http://www.cnblogs.com/why168888/p/5965180.html 本文出自:[Edwin博客园] Linux文件和目录权限解读 如何设置Linxu文件和 ...
- linux系统下修改文件夹目录权限
linux系统下修改文件夹目录权限 文件夹权限问题 Linux.Fedora.Ubuntu修改文件.文件夹权限的方法差不多.很多人开始接触Linux时都很头痛Linux的文件权限问题.这里告诉大家如何 ...
- Linux文件及目录权限解析
Linux系统9位基础权限体系 文件权限 * r权限 可读 对文件具有读取及查看文件内容的全新啊 * w权限 可写 对文件具有新增.修改文件内容的权限 ...
随机推荐
- Math.round(11.5) 等于多少?Math.round(-11.5)等于 多少?
Math.round(11.5)的返回值是 12,Math.round(-11.5)的返回值是-11.四舍五 入的原理是在参数上加 0.5 然后进行下取整.
- Python中查看变量的类型,内存地址,所占字节的大小
查看变量的类型 #利用内置type()函数 >>> nfc=["Packers","49"] >>> afc=[" ...
- PCB模块化布局系列之时钟电路设计(晶振、晶体)
一.晶体在一个电路系统中, 时钟是必不可少的一部分.如人的心脏的作用,如果电路系统的时钟出错了,系统就会发生紊乱,因此在PCB 中设计,一个好的时钟电路是非常必要的.我们常用的时钟电路有:晶体.晶振. ...
- 12 Web Development Trends That Will Dominate 2022
12 Web Development Trends That Will Dominate 2022 (mindinventory.com) Progressive Web Apps (PWAs) An ...
- React中Ref 的使用 React-踩坑记_05
React中Ref 的使用 React v16.6.3 在典型的React数据流中,props是父组件与其子组件交互的唯一方式.要修改子项,请使用new props 重新呈现它.但是,在某些情况下,需 ...
- 来扯点ionic3[7] LocalStorage的使用—以登录和注销为例
一般意义上,一个互联网 APP 中的数据主自与服务器的交互,但是对于有些数据,我们希望获取到它们以后能保存,并在全局环境使用,比如用户数据--我们不希望在每个页面都从服务器拉取一遍.这时我们就可以利用 ...
- 小程序wx.previewImage查看图片再次点击返回时重新加载页面问题
wx.previewImage预览图片这个过程到底发生了什么? 首先我们点击图片预览,附上查看图片代码: <image class="headImg" data-src=&q ...
- 动态div点击事件传递对象参数格式-草稿889
<button type='button' style='border: 1px solid #eeeeee;color: #717070;height: 20px;border-radius: ...
- formData请求接口传递参数格式
element ui组件方法的传递 //引入 组件. <el-upload class="avatar-uploader" :action="action" ...
- Windows中Nginx配置nginx.conf不生效解决方法
转:https://lucifer.blog.csdn.net/article/details/83860644?utm_medium=distribute.pc_relevant.none-task ...