2009-03-26

文件夹的读权限和执行权限的区别



文件的读权限是指获得文件夹的文件列表的权限, 而文件的执行权限,是指搜索文件夹的权限,或者说是"通过"该文件夹的权限. 例如,要访问 /home/grep/dirtest/test 这个文件, 首先就需要/home/grep/dirtest这个文件夹的执行权限;如果没有对/home/grep/dirtest的执行权限,那么就算有/home/grep/dirtest/test的读权限也还是读不了/home/grep/dirtest/test这个文件的

grep@ubuntu:~$
grep@ubuntu:~$ ls -ld dirtest/
drwxr-xr-x 2 grep grep 4096 2009-03-26 09:14 dirtest/
grep@ubuntu:~$ ls -l dirtest/
total 4
-rw-r--r-- 1 grep grep 6 2009-03-26 09:15 test
grep@ubuntu:~$ chmod -x dirtest/
grep@ubuntu:~$ ls -ld dirtest/
drw-r--r-- 2 grep grep 4096 2009-03-26 09:14 dirtest/
grep@ubuntu:~$ ls -l dirtest/
ls: cannot access dirtest/test: Permission denied
total 0
-????????? ? ? ? ? ? test

上例中,ls -l dirtest需要对dirtest里的文件执行stat操作,在删除dirtest的执行权限后,就再也不能访问它里面的test文件,所以ls提示错误;但是因为dirtest还有读权限,所以ls -l仍然可以返回它的文件列表

转载请注明出处 http://fornote.blogspot.com

没有评论:

发表评论