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,
but not from my user account:
I don't understand why I can't see files (
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.
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 (
/mediahas
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.
相关文章推荐
- android wifi 无线调试
- 运维入门
- 动态清空 nohup 输出文件
- install scrapy with pip and easy_install
- Linux Shell常用技巧
- Access 2000 数据库 80 万记录通用快速分页类
- 十万条Access数据表分页的两个解决方法
- shell字符串操作详解
- VB6实现连接Access数据库的ADODB代码实现方法
- Shell中删除某些文件外所有文件的3个方法
- Ruby中执行Linux shell命令的六种方法详解
- Access中字段上自动打开的输入法的解决方法
- Access to SQLserver 数据库生迁脚本编写器(DB_CreateSqlEV1.06下载)
- asp Access数据备份,还原,压缩类代码
- VB使用ADO操作Access数据库
- VB使用shell函数打开外部exe程序的实现方法
- Shell编程的一些知识集合
- Shell中的for和while循环详细总结
- 什么是Shell?Shell脚本基础知识详细介绍
- Shell脚本中引用、调用另一个脚本文件的2种方法