LINUX目录的读、写、执行权限的具体含义

来源:互联网 发布:东方网络怎么了 编辑:程序博客网 时间:2024/05/22 06:54

     文件的读写执行权限比较好理解,但是目录的读写执行权限具体含义又是什么呢?

目录读权限:表示用户可以用ls命令将目录下的具体子目录和文件罗列出来。

示例

test1@ubuntu:/home/dyp930/work$ mkdir temptest1@ubuntu:/home/dyp930/work$ ls -lrttotal 4drwxrwxr-x 2 test1 test1 4096 Jun 28 05:32 temptest1@ubuntu:/home/dyp930/work$ chmod u-r temp  //将所属用户对该目录的读权限删除。test1@ubuntu:/home/dyp930/work$ ls -lrttotal 4d-wxrwxr-x 2 test1 test1 4096 Jun 28 05:32 temptest1@ubuntu:/home/dyp930/work$ ls -lrt temp   //发现无法ls 这个目录了。ls: cannot open directory temp: Permission deniedtest1@ubuntu:/home/dyp930/work$ chmod u+r temp  test1@ubuntu:/home/dyp930/work$ ls -lrt temp   //重新添加读权限就可以了。total 0test1@ubuntu:/home/dyp930/work$           //备注,一般所有者对目录是有读写执行权限的。

目录写权限:表示用户可以在该目录下可创建子目录或者文件。

示例

test1@ubuntu:/home/dyp930/work$ ls -lrttotal 4drwxrwxr-x 2 test1 test1 4096 Jun 28 05:32 temptest1@ubuntu:/home/dyp930/work$ chmod u-w temp   //去除目录所有者对该目录的写权限。如下,无法在该目录下创建子目录和文件了。test1@ubuntu:/home/dyp930/work$ cd temptest1@ubuntu:/home/dyp930/work/temp$ ls -lrttotal 0test1@ubuntu:/home/dyp930/work/temp$ mkdir testmkdir: cannot create directory ‘test’: Permission deniedtest1@ubuntu:/home/dyp930/work/temp$ touch test.txttouch: cannot touch ‘test.txt’: Permission deniedtest1@ubuntu:/home/dyp930/work/temp$ 

目录执行权限:表示可以用cd进入该目录

示例

test1@ubuntu:/home/dyp930/work$ ls -lrttotal 4dr-xrwxr-x 2 test1 test1 4096 Jun 28 05:32 temptest1@ubuntu:/home/dyp930/work$ chmod u-x temp     //去除目录所有者对该目录的执行权限,则cd命令无法进入了。test1@ubuntu:/home/dyp930/work$ ls -lrttotal 4dr--rwxr-x 2 test1 test1 4096 Jun 28 05:32 temptest1@ubuntu:/home/dyp930/work$ cd tempbash: cd: temp: Permission deniedtest1@ubuntu:/home/dyp930/work$ 

--完结。


原创粉丝点击