问题描述
我想授予特定用户对特定文件夹的权限,在 Linux 中具有不同级别的权限(读取、写入、执行)。并为某些组做同样的事情。
例如我想给用户:sigmundlucas
权限(读、写)promotional_material
另一个例子是我想给组:testers
权限(执行)development_project_data_directory
我需要从 root 帐户执行所有这些操作,因为相关文件夹在登录用户时不允许使用 chmod
解决方法
这通常是通过 chown
和组来完成的!
为您的用户创建一些群组作为其成员
然后chown
目录为:<group>
例如
groupadd mygroup # create a new group
usermod -aG mygroup myuser # add the group to the user's info
chown :mygroup target_directory # set the group to own the directory
chmod 770 target_directory # root and the group can enter/read/write
如果您不习惯数字,您可以使用 https://chmod-calculator.com/ 之类的网站计算 chmod
问题
- 目录必须是可执行的才能进入
- 用户必须能够读取所有中间路径,您希望他们能够写入