1、在/data/testdir里創建的新文件自動屬于g1組,組g2的成員如:alice能對這些新文件有讀寫權限,組g3的成員如:tom只能對新文件有讀權限,其它用戶(不屬于g1,g2,g3)不能訪問這個文件夾。
[root@localhost testdir]# groupadd g1 [root@localhost testdir]# groupadd g2 [root@localhost testdir]# groupadd g3 [root@localhost testdir]# mkdir -p /date/testdir [root@localhost testdir]# chmod 770 /date/testdir [root@localhost testdir]# chown :g1 /date/testdir [root@localhost testdir]# useradd -G g2 alice [root@localhost testdir]# useradd -G g3 tom [root@localhost testdir]# setfacl -Rm g:g2:rwx /date/testdir/ [root@localhost testdir]# setfacl -Rm g:g3:rx /date/testdir/ [root@localhost testdir]# getfacl /date/testdir/ getfacl: Removing leading '/' from absolute path names # file: date/testdir/ # owner: root # group: g1 user::rwx group::rwx group:g2:rwx //題目要求讀寫,沒有x權限也不行 group:g3:r-x //題目要求讀權限,如果沒有x權限是不能讀的 mask::rwx other::---
2、創建組sales,gid 3000,passwd:centos,sales admins:user2
將用戶user1,user2,user3加入到sales輔助組
希望user1 創建新文件 默認的所屬組為sales
user2將用戶user3從sales組移除
刪除sales,user1,user2
[root@localhost ~]# groupadd -g 3000 sales [root@localhost ~]# gpasswd sales Changing the password for group sales New Password: Re-enter new password: [root@localhost ~]# useradd -G sales user1 [root@localhost ~]# useradd -G sales user2 [root@localhost ~]# useradd -G sales user3 [root@localhost ~]# gpasswd -A user2 sales [root@localhost ~]# usermod -g sales user1 [root@localhost ~]# su - user1 [user1@localhost ~]$ touch user1.txt [user1@localhost ~]$ ls -l user1.txt -rw-r--r-- 1 user1 sales 0 Jul 25 12:28 user1.txt //查看user1創建文件默認屬組為sales [user1@localhost ~]$ exit logout [root@localhost ~]# su user2 [user2@localhost root]$ gpasswd -d user3 sales Removing user user3 from group sales [user2@localhost ~]$ exit logout [root@localhost ~]# userdel -r user1 //刪除用戶 userdel: group user1 not removed because it is not the primary group of user user1. [root@localhost ~]# userdel -r user2 [root@localhost ~]# groupdel sales
原創文章,作者:Lii,如若轉載,請注明出處:http://www.www58058.com/28428