【问题标题】:In a group with read/write/execute permissions in a folder but cannot cd into it在文件夹中具有读/写/执行权限但无法 cd 进入的组中
【发布时间】:2015-06-22 20:26:58
【问题描述】:

我目前正在尝试将用户添加到我在 linux 机器上拥有的 git repo。我进行了组调用 webdev,在其中我使用 useradd 添加了 user1 和 user2。然后我继续将该组添加到文件夹中。然后我使用 chmod 070 更改了文件夹的权限。我重新启动机器。

问题

现在我尝试 cd 进入我刚刚更改权限的文件夹,它说我没有足够的权限,但我在 webdev 组中。

当我列出文件夹时,这就是我得到的

 d---rwx--- 3 user1 webdev 4096 jun 22 14:18 : Git Repo

在 etc/groups 中清楚地列出了组中的 user1 和 user2。

【问题讨论】:

    标签: linux permissions


    【解决方案1】:

    Unix 权限实际上是这样工作的:

    if (you are root) {
        you have 'rwx' permissions for any folder and 'rw' and possibly 'x' for any file
    } else if (you are file's owner) {
        only 'owner' permissions apply to you
    } else if (list of groups you belong to includes file's group) {
        only 'group' permissions apply to you
    } else {
        only 'other' permissions apply to you
    }
    

    因此,如果您是 user1 并且文件夹的所有者是 user1 并且文件夹具有 '---rwx---' 权限,那么所有者权限 ('---') 将应用于您并且您无权访问。

    【讨论】:

      【解决方案2】:

      您的问题与 git 无关。您应该使用chmod 770,而不是在您的目录上运行chmod 070。对user1 没有rwx 权限可能会覆盖组权限,从而将user1 锁定在外。 user2能进去吗?

      奇怪的是,当我在 Ubuntu 12.04、OS X Mountain Lion 和 OS X Yosemite 上进行此测试时,我被锁定了,但在 OS X Lion 上却没有。

      【讨论】:

      • 用户 2 无法进入,但我不知道用户权限像上面描述的 Roman 一样工作。
      猜你喜欢
      • 1970-01-01
      • 2012-05-31
      • 1970-01-01
      • 1970-01-01
      • 2011-01-23
      • 1970-01-01
      • 1970-01-01
      • 2011-08-21
      • 2020-12-12
      相关资源
      最近更新 更多