我在我的服务器上拥有root权限,并且我想为特定组和用户授予权限.有一种情况,有目录树:
dir1
├── subdir1
├── subdir2
├── subdir3
我有三个用户(user1,user2,user3) – 我希望他们每个人只有一个目录(user1 – subdir1,user2 – subdir2,user3 – subdir3)的权限. User1应该无法看到int subdir2或subdir3,但是他看不到它们存在,与其他用户及其目录相同.
我使用getfacl和setfacl命令给出了持久性.
这些用户对dir1和subdirs有什么权限?
解决方法:
要允许所有用户在dir1中查看文件列表,请将权限0755设置为此文件夹
$chmod dir1 0755
要分隔对子文件夹的访问,请将所有者分配给每个文件夹:
$cd dir1
$chown user1:user1 -R subdir1
$chown user2:user2 -R subdir2
$chown user3:user3 -R subdir3
现在让子文件夹只对他们的所有者可读:
$chmod user* 0700
现在所有用户都看到文件夹user *存在,但是他们只能输入自己的文件夹
更新
抱歉,无法在评论中设置文本格式.
When I have more users than these three, and I want only these three
to be able to enter dir1 – what then?
然后,您必须为它们分配一个特殊组,并允许该组读取dir1的内容.
创建组特殊用户
$groupadd specialusers
添加该组中的用户
$usermod -aG specialusers user1
$usermod -aG specialusers user2
$usermod -aG specialusers user3
允许特殊用户阅读文件夹
$chown root:specialusers dir1
$chmod dir1 0750
现在,只有来自组特殊用户的用户才能在dir1下看到文件夹列表
标签:linux,debian,ubuntu,permissions
来源: https://codeday.me/bug/20190825/1719237.html