您的位置:首页 > 运维架构 > Shell

File permissions: why can't I list a directory?

2015-09-18 16:31 537 查看
I am able to list directories in a root shell,
root@ThinkPad:~# ll /media/
total 36
drwxr--r--  6 root root  4096 2011-05-12 16:41 ./
drwxr-xr-x 22 root root  4096 2011-05-12 13:14 ../
drwxr-xr-x  5 root root  4096 2011-05-12 15:56 hd/
drwxr--r--  2 root root 16384 2011-05-12 14:20 lost+found/
drwxr-xr-x  5 root root  4096 2011-05-12 16:34 main/
drwxr--r--  4 root root  4096 2011-05-12 16:41 .Trash-0/


but not from my user account:
alex@ThinkPad:~$ ll /media/
ls: cannot access /media/..: Permission denied
ls: cannot access /media/hd: Permission denied
ls: cannot access /media/lost+found: Permission denied
ls: cannot access /media/.Trash-0: Permission denied
ls: cannot access /media/.: Permission denied
ls: cannot access /media/main: Permission denied
total 0
d????????? ? ? ? ?                ? ./
d????????? ? ? ? ?                ? ../
d????????? ? ? ? ?                ? hd/
d????????? ? ? ? ?                ? lost+found/
d????????? ? ? ? ?                ? main/
d????????? ? ? ? ?                ? .Trash-0/


I don't understand why I can't see files (
/media
 has
a+r permission).

Answer:

To be able to "enter" a directory, which is kind of a prerequisite for listing its content, you also need the +x permission.

Also note that this is a requirement all the way from the top (root) of the directory structure. To be able to enter a /foo/bar/baz directory a user needs to have the +x permission on every single intermediate directory.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  shell access