chmod:无法读取目录“。”:权限被拒绝 [英] chmod: cannot read directory `.': Permission denied

查看:419
本文介绍了chmod:无法读取目录“。”:权限被拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图递归更改数据目录的目录和子目录的权限,并遇到以下错误。有人可以提供以下错误的输入吗?

I am trying to recursively change the permission of directories and sub-directories for "data" directory and running into following error..can someone provide inputs on the below error?

<username:/local/mnt/workspace/data>chmod -R 0644 .
chmod: cannot read directory `.': Permission denied


推荐答案

目录需要执行权限集才能查看其内容。

Directories need the execute permission set in order to see their contents.

来自 http://content.hccfl.edu/pollock/AUnix1/FilePermissions.htm


您可以这样考虑对目录的读取和执行:目录是数据文件,其中包含每个文件的两个信息,即文件名和索引节点号。需要读取权限才能访问目录中的文件名。如果您已经知道文件名,则需要执行(aka搜索)权限才能访问目录中文件的索引节点。

You can think of read and execute on directories this way: directories are data files that hold two pieces of information for each file within, the file's name and it's inode number. Read permission is needed to access the names of files in a directory. Execute (a.k.a. search) permission is needed to access the inodes of files in a directory, if you already know the file's name.

何时您将目录权限更改为644,尽管可以读取该目录以查看其存在,但无法读取该目录中的文件。

When you change a directory permission to 644, you are unable to read the files in that directory although you can read that directory to see it exists.

您需要执行以下操作:

You need to do this:

$ chmod -R 0755 .

更好的方法是,如果您只想关闭

A better way might be to use string permission if you simply want to turn off

否则,您可以看到目录,但不能访问该目录中的信息。

Otherwise, you can see the directory, but not access the information in that directory.

您最好改用相对权限的绝对权限:

You maybe better off using relative permissions instead of absolute permissions:

$ chmod -R go-w .

将从组和其他对象中删除写权限,但不会触摸执行权限。

Will remove write permission from group and other, but not touch execute permission.

您也可以使用 find 来设置目录或设置文件:

You can also use find just to set the directories or just to set files:

$ find . -type d -exec chmod 755 {} \;

这只会触摸目录,设置所有目录的读取和执行权限,并设置所有者的写入权限。这样,您就不会对文件本身设置执行权限。

This will only touch directories, setting read and execute permission on all directories and setting write permission for the owner. This way, you're not setting execute permission on files themselves.

这篇关于chmod:无法读取目录“。”:权限被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆