在实验一的基础上,
要求:用户组admins(包括sqa和sqb两个用户)对dirtest没有写权限,但用户sqb有写权限。
解决方法:使用acl赋予用户组admins 权限为r-x,赋予用户sqa权限为rwx
1.在实验一中,对于dirtest文件夹,用户sqa权限为---,是acl控制的;用户sqb权限为rwx,不是acl控制的;
现在先对用户组admins设置acl
[root@itpro ~]# setfacl -m g:admins:r-x /dirtest/
[root@itpro ~]# getfacl /dirtest/
getfacl: Removing leading '/' from absolute path names
# file: dirtest/
# owner: root
# group: root
user::rwx
user:sqa:---
group::r-x
group:admins:r-x
mask::r-x
other::rwx
(注:此时,用户sqa的权限仍然是---,用户sqb的权限则随用户组admins为r-x
测试结果如下:
[root@itpro ~]# su sqa
[sqa@itpro root]$ ls /dirtest/
ls: cannot open directory /dirtest/: Permission denied
[sqa@itpro root]$ exit
exit
[root@itpro ~]# su sqb
[sqb@itpro root]$ ls /dirtest/
t01 t02
[sqb@itpro root]$ touch /dirtest/t03
touch: cannot touch `/dirtest/t03': Permission denied
[sqb@itpro root]$ exit
exit
[root@itpro ~]#
以上是测试结果)
2.删除实验一中对用户sqa设置的acl
(注:在实验一步骤2中,使用命令setfacl -m u:sqa:--- /dirtest/ 对用户sqa设置了权限)
[root@itpro ~]# setfacl -x u:sqa /dirtest/
[root@itpro ~]# getfacl /dirtest/
getfacl: Removing leading '/' from absolute path names
# file: dirtest/
# owner: root
# group: root
user::rwx
group::r-x
group:admins:r-x
mask::r-x
other::rwx
(注:如果没有做实验一,直接做实验二,对用户组admins设置acl后,看到的结果便是这个,当然,other权限默认应为r-w,实验一中改了)
