为什么我不能在Linux中查看目录?

时间:2022-07-11 15:22:02

I am setting up a Linux web server running apache. I uploaded and untared my web sites files. The files in the main directory are all visible when I am SSH'd into the system. However, I am blocked from all subdirectories. If I write:

我正在设置一个运行apache的Linux web服务器。我上传和释放我的网站文件。当SSH进入系统时,主目录中的文件都是可见的。但是,我被所有子目录阻塞。如果我写:

# cd images

Then I get the error:

然后我得到了误差:

-bash: cd: images: Permission denied

I am signed in as ec2-user. I untarred the stuff as ec2-user and I doubt there was any permissions in the tar file since I created the archive on a Windows system. The weird thing is that I am the owner of this directory. Here is a snippet of the command: ls -l

我注册为ec -user。我将这个文件解压为ec -user,我怀疑tar文件中没有任何权限,因为我在Windows系统上创建了存档。奇怪的是我是这个目录的所有者。下面是命令的一个片段:ls -l

drw-rw-r-- 19 ec2-user ec2-user      4096 May  4 04:09 images

When I do "sudo su" and then type the command cd images everything is fine. Why do I get "Permission denied" as ec2-user if I am the owner and have rw permission?

当我做“sudo su”,然后输入命令cd图像时,一切正常。如果我是ec2用户,并且有rw权限,为什么我要被拒绝?

2 个解决方案

#1


2  

You need execute permission too:

你也需要执行许可:

chmod +x images

should take care of it. The execute permission for directories translates to a "traverse directory" permission.

应该照顾好它。目录的执行权限转换为“遍历目录”权限。

#2


1  

It misses executable bit on the directory which is essential to be able to cd in there.

它会丢失目录上的可执行位,这对于cd在目录中很重要。

A quick fix would be to run in the directory where you unpacked your stuff:

快速修复将会在你打开你的东西的目录中运行:

# find . -type d | xargs chmod a+x

If you have directories with spaces in them, use the following:

如果目录中有空格,请使用以下内容:

# find . -type d -exec chmod a+x "{}" \;

#1


2  

You need execute permission too:

你也需要执行许可:

chmod +x images

should take care of it. The execute permission for directories translates to a "traverse directory" permission.

应该照顾好它。目录的执行权限转换为“遍历目录”权限。

#2


1  

It misses executable bit on the directory which is essential to be able to cd in there.

它会丢失目录上的可执行位,这对于cd在目录中很重要。

A quick fix would be to run in the directory where you unpacked your stuff:

快速修复将会在你打开你的东西的目录中运行:

# find . -type d | xargs chmod a+x

If you have directories with spaces in them, use the following:

如果目录中有空格,请使用以下内容:

# find . -type d -exec chmod a+x "{}" \;