Linux directory permissions for different groups

前端 未结 4 563
野的像风
野的像风 2021-01-31 23:21

I\'m having two directories: \"public\" and \"private\". I have three users: \"chris\", \"john\", \"dan\". I have two groups: \"pub\", \"priv\" and \"god\".

  • The g
4条回答
  •  醉梦人生
    2021-01-31 23:38

    Well, I know this is relatively old, but twalberg is correct: there's actually a relatively easy way to accomplish this with POSIX ACL's. They've existed since the late 90's/early 2000's so I don't know why more people don't use them.

    How to do it: Do as you've already done, then simply execute this command:

    # setfacl -m g:god:rwx public private
    

    and in one command you get what you're wanting. You'll spend forever trying to figure out how to do it using ONLY traditional unix permissions.

    Mikic's advice may still be good (depending on what you're trying to accomplish), and it might be more straight forward to reference as few groups as possible in your permissions (or maybe you want it to be apparent that "chris" isn't a regular user, but an administrative one, again it depends on what you want to construct).

    I offered something closer to what you're trying to accomplish, because there may be situations where you're trying to give a secondary user/group access to a directory but you don't want to choose between "chris" not getting access to these two directories and "chris" getting access to all those other files and directories "pub" and "priv" might have access to. With ACL's you don't have to make those choices, which is why they were added and are now a core part of most Unix (and BSD and Linux) platforms.

提交回复
热议问题