[root@localhost Desktop]# groupadd shengchan
[root@localhost Desktop]# groupadd caiwu
[root@localhost Desktop]# groupadd jishu
[root@localhost Desktop]# useradd -g shengchan adminsc
[root@localhost Desktop]# useradd -g caiwu admincw
[root@localhost Desktop]# useradd -g jishu adminjs
[root@localhost Desktop]# useradd -G shengchan tom
[root@localhost Desktop]# useradd -G caiwu harry
[root@localhost Desktop]# useradd -G jishu leo
[root@localhost Desktop]# useradd admin
[root@localhost Desktop]# mkdir /cw /sc /js
[root@localhost Desktop]# chown admincw.caiwu /cw
[root@localhost Desktop]# chown adminjs.jishu /js
[root@localhost Desktop]# chown adminsc.shengchan /sc
[root@localhost Desktop]# chmod 3770 /cw
[root@localhost Desktop]# chmod 3770 /js
[root@localhost Desktop]# chmod 3770 /sc
[root@localhost Desktop]# setfacl -m u:admin:rwx /cw
[root@localhost Desktop]# setfacl -m u:admin:rwx /sc
[root@localhost Desktop]# setfacl -m u:admin:rwx /js
验证:
[root@localhost Desktop]# id adminsc
uid=1006(adminsc) gid=1003(shengchan) groups=1003(shengchan)
[root@localhost Desktop]# id admincw
uid=1007(admincw) gid=1004(caiwu) groups=1004(caiwu)
[root@localhost Desktop]# id adminjs
uid=1008(adminjs) gid=1005(jishu) groups=1005(jishu)
[root@localhost Desktop]# id tom
uid=1002(tom) gid=1006(tom) groups=1006(tom),1003(shengchan)
[root@localhost Desktop]# id harry
uid=1003(harry) gid=1007(harry) groups=1007(harry),1004(caiwu)
[root@localhost Desktop]# id admin
uid=1005(admin) gid=1009(admin) groups=1009(admin)
[root@localhost Desktop]# ls -ld /cw
drwxrws--T+ 2 admincw caiwu 6 Jul 14 16:59 /cw
[root@localhost Desktop]# ls -ld /js
drwxrws--T+ 2 adminjs jishu 6 Jul 14 16:59 /js
[root@localhost Desktop]# ls -ld /sc
drwxrws--T+ 2 adminsc shengchan 6 Jul 14 16:59 /sc
[root@localhost Desktop]# su - admin
[admin@localhost ~]$ cd /cw
[admin@localhost cw]$ exit
logout
[root@localhost Desktop]# su - tom
Last failed login: Sun Jul 14 17:17:07 CST 2019 on pts/2
There was 1 failed login attempt since the last successful login.
[tom@localhost ~]$ cd /cw
-bash: cd: /cw: Permission denied