Linux 为什么我无法访问此文件夹?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10565367/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 06:17:12  来源:igfitidea点击:

Why can't I access this folder?

linuxdirectoryext4home-directory

提问by Rick Hodgin

A while back I bought a 1TB USB external drive. I formatted it ext4 in Ubuntu and copied a bunch of files / folders to it from several machines, all to /home/machinename/whatever, respectively.

不久前,我买了一个 1TB 的 USB 外置驱动器。我在 Ubuntu 中将其格式化为 ext4,并将一堆文件/文件夹从几台机器复制到它,分别复制到 /home/machinename/whatever。

At some point I ran a chmod -R shell command on it to change the permissions. That was months ago and I don't remember what I typed but it made the drive so I could only access its /home folder as root. This wasn't a problem because I could still access everything, but today I decided to try to fix it.

在某些时候,我在其上运行了一个 chmod -R shell 命令来更改权限。那是几个月前的事了,我不记得我输入了什么,但它制作了驱动器,所以我只能以 root 身份访问它的 /home 文件夹。这不是问题,因为我仍然可以访问所有内容,但今天我决定尝试修复它。

I went to my shell as root, went to that drive and typed:

我以 root 身份进入我的 shell,进入那个驱动器并输入:

chown -R rick:rick ./
chmod -R 666 ./

It seemed to work. That home directory and everything else in it now shows up as rw for each:

它似乎奏效了。该主目录及其中的所有其他内容现在都显示为 rw:

rick@rick64:/media/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee$ ls -l
drw-rw-rw- 7 rick rick 4096 2012-03-04 13:08 home

So, if I try to access that directory with the shell, I get:

因此,如果我尝试使用 shell 访问该目录,则会得到:

rick@rick64:/media/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee$ ls -l
drw-rw-rw- 7 rick rick 4096 2012-03-04 13:08 home
rick@rick64:/media/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee$ cd home
bash: cd: home: Permission denied
rick@rick64:/media/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee$ _

When I access it with nautilus I can see the multiple machine names within the /home/ folder, but they all appear with a file icon. I can right-click on them and choose "Properties" but it won't let me see the permissions.

当我使用 nautilus 访问它时,我可以看到 /home/ 文件夹中的多个机器名称,但它们都带有一个文件图标。我可以右键单击它们并选择“属性”,但它不会让我看到权限。

Am baffled. Why can't I access that folder? I'm the owner? I'm even the group. I have r/w privileges. What am I doing wrong?

我很困惑。为什么我无法访问该文件夹?我是业主?我什至是这个群体。我有读写权限。我究竟做错了什么?

采纳答案by J?rg W Mittag

You're neither trying to read (list) nor write (create a new entry) the directory. You want to enter it, therefore you need (slightly misnamed in the case of directories) exexute permissions.

您既不尝试读取(列出)也不尝试写入(创建新条目)目录。您想输入它,因此您需要(在目录的情况下稍微错误命名)e xexute 权限。