(1)葫盼、創(chuàng)建組distro残腌,其GID為2019;
[root@centos8 etc]# groupadd -g2019 distro
(2)贫导、創(chuàng)建用戶mandriva, 其ID號為1005抛猫;基本組為distro;
useradd -u1005 -gdistro mandriva
(3)脱盲、創(chuàng)建用戶mageia邑滨,其ID號為1100,家目錄為/home/linux;
useradd -u1100 -d/home/linux mageia
(4)钱反、給用戶mageia添加密碼掖看,密碼為mageedu,并設置用戶密碼7天后過期
passwd mageia
passwd -x 7 mageia
(5)面哥、刪除mandriva哎壳,但保留其家目錄;
[root@centos8 etc]# userdel mandriva
[root@centos8 etc]# cd /home/mandriva/
[root@centos8 mandriva]#
(6)尚卫、創(chuàng)建用戶slackware归榕,其ID號為2002,基本組為distro吱涉,附加組peguin刹泄;
[root@centos8 etc]# useradd -u 2002 -g distro slackware
[root@centos8 etc]# id slackware
uid=2002(slackware) gid=2019(distro) groups=2019(distro)
[root@centos8 etc]# groupmems -a slackware -g peguin
groupmems: group 'peguin' does not exist in /etc/group
[root@centos8 etc]# groupadd peguin
[root@centos8 etc]# groupmems -a slackware -g peguin
[root@centos8 etc]# id slackware
uid=2002(slackware) gid=2019(distro) groups=2019(distro),2020(peguin)
(7)外里、修改slackware的默認shell為/bin/tcsh;
[root@centos8 etc]# usermod -s /bin/tcsh slackware
[root@centos8 etc]# cat /etc/passwd|grep slackware
slackware:x:2002:2019::/home/slackware:/bin/tcsh
(8)特石、為用戶slackware新增附加組admins盅蝗,并設置不可登陸。
[root@centos8 etc]# groupadd admins
[root@centos8 etc]# groupmems -a slackware -g admins
[root@centos8 etc]# id slackware
uid=2002(slackware) gid=2019(distro) groups=2019(distro),2020(peguin),2021(admins)
[root@centos8 etc]# usermod -s /sbin/nologin slackware #不可登陸
5姆蘸、創(chuàng)建用戶user1墩莫、user2、user3逞敷。在/data/下創(chuàng)建目錄test
[root@centos8 data]# ll
total 0
drwxr-xr-x. 2 root root 6 Dec 2 11:37 test
(1)狂秦、目錄/data/test屬主、屬組為user1
[root@centos8 data]# chown user1 test
[root@centos8 data]# chgrp user1 test
[root@centos8 data]# ll
total 0
drwxr-xr-x. 2 user1 user1 6 Dec 2 11:37 test
(2)推捐、在目錄屬主裂问、屬組不變的情況下,user2對文件有讀寫權限
[root@centos8 data]# chmod o+rw test
[root@centos8 data]# ll
total 0
drwxr-xrwx. 2 user1 user1 6 Dec 2 11:37 test
(3)玖姑、user1在/data/test目錄下創(chuàng)建文件a1.sh, a2.sh, a3.sh, a4.sh愕秫,設置所有用戶都不可刪除a1.sh,a2.sh文件焰络、除了user1及root之外戴甩,所有用戶都不可刪除a3.sh, a4.sh
[root@centos8 test]# touch a{1..4}.sh #創(chuàng)建文件
[root@centos8 test]# ls
a1.sh a2.sh a3.sh a4.sh
[root@centos8 test]# chattr +i a1.sh #設置特殊權限
[root@centos8 test]# chattr +i a2.sh
#facl設置特殊權限
[root@centos8 test]# setfacl -m u:user1:rw a3.sh
[root@centos8 test]# setfacl -m u:user1:rw a4.sh
[root@centos8 test]# getfacl a3.sh
# file: a3.sh
# owner: root
# group: root
user::rw-
user:user1:rw-
group::r--
mask::rw-
other::r--
(4)、user3增加附加組user1闪彼,同時要求user1不能訪問/data/test目錄及其下所有文件
[root@centos8 test]# groupmems -a user3 -g user1 #為user3增加附加組
[root@centos8 test]# id user3
uid=2005(user3) gid=2005(user3) groups=2005(user3),2003(user1)
[root@centos8 test]# setfacl -m user1:0 /data
[root@centos8 test]# su - user1
[user1@centos8 ~]$ cd /data
-bash: cd: /data: Permission denied
(5)甜孤、清理/data/test目錄及其下所有文件的acl權限
[root@centos8 test]# setfacl -b a3.sh
[root@centos8 test]# setfacl -b a4.sh
[root@centos8 test]# chattr -i a1.sh a2.sh
[root@centos8 test]# setfacl -b /data