▲就業(yè)班和全程班的小伙伴看這里:(學(xué)習(xí)老王視頻的作業(yè)第5-6節(jié))
1嗤无、顯示/etc目錄下抬驴,以非字母開頭秤涩,后面跟了一個字母以及其它任意長度任意字符的文件或目錄
[root@centos7 ~]#ll -d /etc/[^[:alpha:]][:alpha:]*
-rw-r--r-- 1 root root 0 Feb 22 20:08 /etc/2a444.log
2陶舞、復(fù)制/etc目錄下所有以p開頭抹剩,以非數(shù)字結(jié)尾的文件或目錄到/tmp/mytest1目錄中撑帖。
[root@centos7 ~]#mkdir /tmp/mytest1
[root@centos7 ~]#cp -avr /etc/p*[^0-9] /tmp/mytest1
3、將/etc/issue文件中的內(nèi)容轉(zhuǎn)換為大寫后保存至/tmp/issue.out文件中
[root@centos7 ~]#cat /etc/issue|tr "a-z" "A-Z" >/tmp/issue.out
[root@centos7 ~]#cat /tmp/issue.out
\S
KERNEL \R ON AN \M
4澳眷、請總結(jié)描述用戶和組管理類命令的使用方法并完成以下練習(xí):
(1)胡嘿、創(chuàng)建組distro,其GID為2019钳踊;
[root@centos7 ~]#groupadd distro -g 2019
[root@centos7 ~]#getent group distro
distro:x:2019:
(2)衷敌、創(chuàng)建用戶mandriva,?其ID號為1005;基本組為distro拓瞪;
[root@centos7 ~]#useradd mandriva -u 1005 -g distro
[root@centos7 ~]#id mandriva
uid=1005(mandriva) gid=2019(distro) groups=2019(distro)
(3)缴罗、創(chuàng)建用戶mageia,其ID號為1100祭埂,家目錄為/homenux;
[root@centos7 ~]#useradd mageia -u 1100 -d /homenux
[root@centos7 ~]#id mageia
uid=1100(mageia) gid=1100(mageia) groups=1100(mageia)
[root@centos7 ~]#ll -a /homenux
total 16
(4)面氓、給用戶mageia添加密碼,密碼為mageedu蛆橡,并設(shè)置用戶密碼7天后過期
[root@centos7 ~]#getent shadow mageia
mageia:$6$TSa1n5SM$LObRg2T6VWhlLiYcWVKwm5gFURktqK5sMyMSCVsg2UHjG/wUUmfAII59HtXo4rUv2nugNNnmqz7.1NgS/scTX1:18315:0:99999:7:::
[root@centos7 ~]#echo "mageedu"|passwd -x 7 --stdin mageia
Adjusting aging data for user mageia.
passwd: Success
[root@centos7 ~]#getent shadow mageia
mageia:$6$TSa1n5SM$LObRg2T6VWhlLiYcWVKwm5gFURktqK5sMyMSCVsg2UHjG/wUUmfAII59HtXo4rUv2nugNNnmqz7.1NgS/scTX1:18315:0:7:7:::
(5)舌界、刪除mandriva,但保留其家目錄航罗;
[root@centos7 ~]#getent passwd mandriva
mandriva:x:1005:2019::/home/mandriva:/bin/bash
[root@centos7 ~]#userdel mandriva
[root@centos7 ~]#ls /home
chen? chi? mandriva? rose? rost? slackware
(6)禀横、創(chuàng)建用戶slackware,其ID號為2002粥血,基本組為distro柏锄,附加組peguin酿箭;
[root@centos7 ~]#useradd slackware -u 2002 -g distro -G peguin
[root@centos7 ~]#id slackware
uid=2002(slackware) gid=2019(distro) groups=2019(distro),2020(peguin)
(7)、修改slackware的默認(rèn)shell為/bin/tcsh趾娃;
[root@centos7 ~]#getent passwd slackware
slackware:x:2002:2019::/home/slackware:/bin/bash
[root@centos7 ~]#usermod -s /bin/tcsh slackware
[root@centos7 ~]#getent passwd slackware
slackware:x:2002:2019::/home/slackware:/bin/tcsh
(8)缭嫡、為用戶slackware新增附加組admins
[root@centos7 ~]#id slackware
uid=2002(slackware) gid=2019(distro) groups=2019(distro),2020(peguin)
[root@centos7 ~]#usermod -aG admins slackware
[root@centos7 ~]#id slackware
uid=2002(slackware) gid=2019(distro) groups=2019(distro),1002(admins),2020(peguin)
或
[root@centos7 ~]#id slackware
uid=2002(slackware) gid=2019(distro) groups=2019(distro),2020(peguin)
[root@centos7 ~]#gpasswd -a slackware admins
Adding user slackware to group admins
[root@centos7 ~]#id slackware
uid=2002(slackware) gid=2019(distro) groups=2019(distro),1002(admins),2020(peguin)
或
[root@centos7 ~]#id slackware
uid=2002(slackware) gid=2019(distro) groups=2019(distro),2020(peguin)
[root@centos7 ~]#groupmems -a slackware -g admins
[root@centos7 ~]#id slackware
uid=2002(slackware) gid=2019(distro) groups=2019(distro),1002(admins),2020(peguin)