微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

unix – chmod:无法读取目录`.’:权限被拒绝[已关闭]

我正在尝试递归地更改“data”目录的目录和子目录的权限,并运行到以下错误中.有人可以在以下错误中提供输入?
<username:/local/mnt/workspace/data>chmod -R 0644 .
chmod: cannot read directory `.': Permission denied
目录需要执行权限集才能查看其内容.

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

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时,您无法读取该目录中的文件,尽管您可以读取该目录以查看该目录的存在.

你需要这样做:

$chmod -R 0755 .

一个更好的方法可能是使用字符串权限,如果你只想关闭

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

你最好使用相对权限而不是绝对权限:

$chmod -R go-w .

删除组和其他的写入权限,但不触摸执行权限.

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

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

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

原文地址:https://www.jb51.cc/bash/386330.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐