linux权限问题总结
2015-11-15 13:46
363 查看
在linux系统中,一切皆是文件,一切文件皆有权限
目录是一个特殊的文件,而目录记录的是此目录下所有文件和目录的权限
在linux系统中,权限分为r(可读)w(可写)x(可执行)
权限的是针对用户的owner(主)group(组)other(其它用户)
对于一个用户来说,没有任何一个用户是没有组的,在新建一个用户的时候,如果没有给此用户指定组,系统则自动以此用户名新建一个组。
通过以上的实验可以得出结论:在目录456拥有rwx权限的时候,目录123只有在拥有r-x,-wx,–x权限的时候,才可以在目录456下新建、查看文件或目录。
在将目录123的权限设置成–x,目录456的权限设置成–x,则无法查看目录123、456下的任何内容,也无法在目录123下新建文件,但是却可以在目录456下新建文件.
示例:
目录是一个特殊的文件,而目录记录的是此目录下所有文件和目录的权限
在linux系统中,权限分为r(可读)w(可写)x(可执行)
权限的是针对用户的owner(主)group(组)other(其它用户)
对于一个用户来说,没有任何一个用户是没有组的,在新建一个用户的时候,如果没有给此用户指定组,系统则自动以此用户名新建一个组。
[test1@localhost ~]$ mkdir 123 //新建一个目录 [test1@localhost ~]$ ll //查看该目录的权限 总用量 4 drwxrwxr-x. 2 test1 test1 4096 11月 15 09:39 123 [test1@localhost ~]$ cd 123 //进入目录123下 [test1@localhost 123]$ mkdir 456 //新建一个目录456 [test1@localhost 123]$ ll //查看目录456的权限 总用量 4 drwxrwxr-x. 2 test1 test1 4096 11月 15 09:39 456
[test1@localhost ~]$ chmod 400 123 [test1@localhost ~]$ ll 总用量 4 dr--------. 3 test1 test1 4096 11月 15 09:39 123 [test1@localhost ~]$ touch ./123/456/123.txt touch: 无法创建"./123/456/123.txt": 权限不够 [test1@localhost ~]$ chmod 200 123 [test1@localhost ~]$ ll 总用量 4 d-w-------. 3 test1 test1 4096 11月 15 09:39 123 [test1@localhost ~]$ touch ./123/456/123.txt touch: 无法创建"./123/456/123.txt": 权限不够 [test1@localhost ~]$ chmod 100 123 [test1@localhost ~]$ ll 总用量 4 d--x------. 3 test1 test1 4096 11月 15 09:39 123 [test1@localhost ~]$ touch ./123/456/123.txt [test1@localhost ~]$ ll ./123/456 总用量 0 -rw-rw-r--. 1 test1 test1 0 11月 15 10:56 123.txt [test1@localhost ~]$ chmod 600 123 [test1@localhost ~]$ ll 总用量 4 drw-------. 3 test1 test1 4096 11月 15 09:39 123 [test1@localhost ~]$ touch ./123/456/123.txt touch: 无法创建"./123/456/123.txt": 权限不够 [test1@localhost ~]$ chmod 300 123 [test1@localhost ~]$ ll 总用量 4 d-wx------. 3 test1 test1 4096 11月 15 09:39 123 [test1@localhost ~]$ touch ./123/456/123.txt [test1@localhost ~]$ ll ./123/456 总用量 0 -rw-rw-r--. 1 test1 test1 0 11月 15 11:20 123.txt [test1@localhost ~]$ chmod 500 123 [test1@localhost ~]$ ll 总用量 4 dr-x------. 3 test1 test1 4096 11月 15 09:39 123 [test1@localhost ~]$ touch ./123/456/123.txt [test1@localhost ~]$ ll ./123/456 总用量 0 -rw-rw-r--. 1 test1 test1 0 11月 15 11:21 123.txt
通过以上的实验可以得出结论:在目录456拥有rwx权限的时候,目录123只有在拥有r-x,-wx,–x权限的时候,才可以在目录456下新建、查看文件或目录。
在将目录123的权限设置成–x,目录456的权限设置成–x,则无法查看目录123、456下的任何内容,也无法在目录123下新建文件,但是却可以在目录456下新建文件.
示例:
[test1@localhost ~]$ chmod 100 123 [test1@localhost ~]$ chmod 100 ./123/456 [test1@localhost ~]$ ll ./123/456 ls: 无法打开目录./123/456: 权限不够 [test1@localhost ~]$ touch ./123/123.txt touch: 无法创建"./123/123.txt": 权限不够 [test1@localhost ~]$ touch ./123/456/123.txt [test1@localhost ~]$ cd 123 [test1@localhost 123]$ ll ls: 无法打开目录.: 权限不够 [test1@localhost 123]$ cd 456 [test1@localhost 456]$ cd .. [test1@localhost 123]$ cd ..
相关文章推荐
- Linux socket 初步
- linux lsof详解
- linux 文件权限
- Linux 执行数学运算
- 10 篇对初学者和专家都有用的 Linux 命令教程
- Linux 与 Windows 对UNICODE 的处理方式
- Ubuntu12.04下QQ完美走起啊!走起啊!有木有啊!
- 解決Linux下Android开发真机调试设备不被识别问题
- 运维入门
- 运维提升
- Linux 自检和 SystemTap
- Ubuntu Linux使用体验
- c语言实现hashmap(转载)
- Linux 信号signal处理机制
- linux下mysql添加用户
- Scientific Linux 5.5 图形安装教程
- 基于 Linux 集群环境上 GPFS 的问题诊断
- 谁是桌面王者?Win PK Linux三大镇山之宝
- vivi下重新调整分区