[root@centos8mini data]# ls /etc/[^[:alpha:]][[:alpha:]].*
[root@centos8mini data]# cp -avpt /tmp/mytest1 /etc/p*[^[:digit:]]
[root@centos8mini data]# cat /etc/issue | tr 'a-z' 'A-Z' | tee /tmp/issue.out \S KERNEL \R ON AN \M
(1)、建立組distro,其GID爲2019;linux
[root@centos8mini data]# groupadd -g 2019 distro [root@centos8mini data]# getent group distro distro:x:2019:
(2)、建立用戶mandriva, 其ID號爲1005;基本組爲distro;git
[root@centos8mini data]# useradd -u 1005 -g distro mandriva [root@centos8mini data]# id mandriva uid=1005(mandriva) gid=2019(distro) groups=2019(distro)
(3)、建立用戶mageia,其ID號爲1100,家目錄爲/home/linux;shell
[root@centos8mini data]# useradd -u 1100 -d /home/liunx mageia [root@centos8mini data]# getent passwd mageia mageia:x:1100:1100::/home/liunx:/bin/bash
(4)、給用戶mageia添加密碼,密碼爲mageedu,並設置用戶密碼7天后過時centos
[root@centos8mini data]# echo mageedu | passwd --stdin mageia [root@centos8mini data]# passwd -x 7 mageia
(5)、刪除mandriva,但保留其家目錄;bash
[root@centos8mini data]# userdel mandriva
(6)、建立用戶slackware,其ID號爲2002,基本組爲distro,附加組peguin;ide
[root@centos8mini data]# groupadd peguin [root@centos8mini data]# useradd -u 2002 -g distro -G peguin slackware
(7)、修改slackware的默認shell爲/bin/tcsh;ui
[root@centos8mini data]# usermod -s /bin/tcsh slackware
(8)、爲用戶slackware新增附加組admins,並設置不可登錄。加密
[root@centos8mini data]# groupadd admins [root@centos8mini data]# usermod -a -G admins -s /sbin/nologin slackware
[root@centos8mini data]# echo user{1..3} | xargs -n 1 useradd [root@centos8mini data]# mkdir -p /data/test
(1)、目錄/data/test屬主、屬組爲user1code
[root@centos8mini data]# chown user1:user1 /data/test
(2)、在目錄屬主、屬組不變的狀況下,user2對文件有讀寫權限get
[root@centos8mini ~]# setfacl -m u:user2:rw /data/test [root@centos8mini ~]# getfacl /data/test getfacl: Removing leading '/' from absolute path names # file: data/test # owner: user1 # group: user1 user::rwx user:user2:rw- group::r-x mask::rwx other::r-x
(3)、user1在/data/test目錄下建立文件a1.sh, a2.sh, a3.sh, a4.sh,設置全部用戶都不可刪除a1.sh,a2.sh文件、除了user1及root以外,全部用戶都不可刪除a3.sh, a4.sh
[root@centos8mini ~]# su - user1 [user1@centos8mini test]$ chmod o+t /data/test [user1@centos8mini ~]$ cd /data/test [user1@centos8mini test]$ touch a{1..4}.sh [user1@centos8mini test]$ su - root -c 'chattr +i /data/test/a1.sh' Password: [user1@centos8mini test]$ su - root -c 'chattr +i /data/test/a2.sh' Password: [user1@centos8mini test]$ su - root -c 'lsattr /data/test/a1.sh /data/test/a2.sh' Password: ----i-------------- /data/test/a1.sh ----i-------------- /data/test/a2.sh
(4)、user3增長附加組user1,同時要求user1不能訪問/data/test目錄及其下全部文件
備註:這道題與第(1)小問題存在衝突,全部者user1對/data/test目錄下即便沒有權限也是能夠刪除的。。。。
[root@centos8mini ~]# groupmems -g user1 -a user3 [root@centos8mini ~]# setfacl -m u:user1:- /data/test [root@centos8mini ~]# getfacl /data/test getfacl: Removing leading '/' from absolute path names # file: data/test # owner: user1 # group: user1 # flags: --t user::rwx user:user1:--- user:user2:rw- group::r-x mask::rwx other::r-x
(5)、清理/data/test目錄及其下全部文件的acl權限
[root@centos8mini ~]# setfacl -b /data/test [root@centos8mini ~]# getfacl /data/test getfacl: Removing leading '/' from absolute path names # file: data/test # owner: user1 # group: user1 # flags: --t user::rwx group::r-x other::r-x