现在我是用户“lawrence.li”,我可以看到具有“读取”权限的目录“lijunda”
但是现在我没有“读取”权限,为什么我还能看到这个目录?
我很困惑“r”和“-”之间有什么区别?没有阅读权限?,谁能告诉我为什么?非常感谢您
尝试一下ls -l /tmp/lijunda,您将看到的只是其中文件的名称——您将无法打开这些文件,甚至无法查看该目录中文件的文件大小、权限等。
这是因为目录本身只包含文件名和 inode 编号——仅此而已。
对文件名的读取访问由读取权限控制。
对目录指向的inode 的访问由执行权限控制,而不是读取权限。inode 包含有关文件的所有实际详细信息,例如文件大小、所有者、权限、上次修改时间以及组成文件内容的二进制数据的物理位置(在您的物理硬盘上)。
要查看目录中文件的名称- 您需要对该目录的读取权限。您不需要执行或写入权限。
要查看目录中文件的详细信息,即查看 inode 内容,您需要对该目录具有执行权限。如果您已经知道文件的名称,则目录的读取权限对于查看文件的详细信息没有任何影响。
要查看您不知道其名称的文件的详细信息,您需要具有读取和执行权限。
最后,要查看文件的内容——您需要:
例如,请参见下文。
$ whoami
vagrant
$ ls -l
total 12
drwxrwx--x 2 pete pete 4096 Dec 24 08:51 execute_only
drwxrwxr-x 2 pete pete 4096 Dec 24 08:52 read_and_execute
drwxrwxr-- 2 pete pete 4096 Dec 24 08:52 read_only
$ ls -l read_only/
ls: cannot access read_only/mysterious_file: Permission denied
total 0
-????????? ? ? ? ? ? mysterious_file
$ cat read_only/mysterious_file
cat: read_only/mysterious_file: Permission denied
$ ls -l execute_only/
ls: cannot open directory execute_only/: Permission denied
$ ls -l execute_only/unicorn_file
-rw-rw-r-- 1 pete pete 55 Dec 24 08:51 execute_only/unicorn_file
$ cat execute_only/unicorn_file
This file only exists for you if you know it's here ;)
$ ls -l read_and_execute/
total 4
-rw-rw-r-- 1 pete pete 83 Dec 24 08:52 jack_sparrow
$ cat read_and_execute/jack_sparrow
"After the reading, you will be executed."
"That's *Captain* Jack Sparrow to you!"
$
Run Code Online (Sandbox Code Playgroud)
*顺便说一下,您还需要对所有父目录一直到 root 的执行权限。
| 归档时间: |
|
| 查看次数: |
3161 次 |
| 最近记录: |