问大家一个 Linux 权限的问题

2018-07-13 16:54:03 +08:00
 AlisaDestiny

我想给一个目录加上可读权限,但是不小心手残了。写成了

sudo chmod -R -o+r files

中间多了个写-(横杠)。 我改正了之后

sudo chmod -R o+r files

又执行了一遍。 然后我就 cd 不进去了。提示"Permission denied".

我想那好吧。我给就给个最开放的权限

sudo chmod -R 777 files

这下是可以 cd 进去了,但是一直给最开放的权限也不行呀。想想一下还是把可执行权限去掉吧,执行了

sudo chmod -R o-x files

然后奇怪的事发生了。我又 cd 不进去了。为什么我只是撤掉了执行权限但是读权限也没了。

与没有知道的大佬,帮忙给个提示。

3397 次点击
所在节点    Linux
22 条回复
z123
2018-07-13 19:34:25 +08:00
三楼正解:cd 进目录需要 x 权限
Vitameans
2018-07-14 00:08:07 +08:00
The execute permission grants the ability to execute a file. This permission must be set for executable programs, in order to allow the operating system to run them. When set for a directory, the execute permission is interpreted as the search permission: it grants the ability to access file contents and meta-information if its name is known, but not list files inside the directory, unless read is set also.

Source: https://en.m.wikipedia.org/wiki/File_system_permissions#Permissions

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/470654

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX