Linux中的目录权限

来源:互联网 发布:英雄杀龙脉探宝数据 编辑:程序博客网 时间:2024/06/05 05:33
对目录的权限有RWX

R:浏览目录的权限
W:在目录中新建,删除,修改,移动等
X:进入该目录的权限,是RW的基础

示例:
下面的示例是只有X权限,可以进入目录,但是不能读写
  1. [root@ora65 /]# chmod 661 arch/ -R
  2. [root@ora65 /]# ll /
  3. drw-rw---x. 2 root root 4096 Aug 30 2016 arch
  4. [root@ora65 /]# su - oracle
  5. [oracle@ora65 /]$ cd arch/
  6. [oracle@ora65 arch]$ ls
  7. ls: cannot open directory .: Permission denied
  8. [oracle@ora65 ~]$ > /arch/111.txt-bash: /arch/111.txt: Permission denied

下面的示例是有RW权限,没有X就不能读写和进入目录
  1. [root@ora65 /]# chmod 666 arch/ -R
  2. [root@ora65 /]# ll /arch/
  3. total 0
  4. -rw-rw-rw- 1 root root 0 Apr 12 10:26 test.txt
  5. [root@ora65 /]# su - oracle
  6. [oracle@ora65 ~]$ cd /arch/
  7. -bash: cd: /arch/: Permission denied
  8. [oracle@ora65 ~]$ ls /arch/
  9. ls: cannot access /arch/test.txt: Permission denied
  10. [oracle@ora65 ~]$ touch /arch/test2.txt
  11. touch: cannot touch `/arch/test2.txt': Permission denied

可以看出对于目录来说,RW权限是基于X的,所以大部分的目录都是对所有的用户有X权限






0 0
原创粉丝点击