顯示/etc目錄下,以非字母開頭,后面跟了一個字母以及其它任意長度任意字符的文件或目錄
- ls /etc/[^[:alpha:]]
復(fù)制/etc目錄下所有以p開頭,以非數(shù)字結(jié)尾的文件或目錄到/tmp/mytest1目錄中。
- cp -r /etc/p*[^[:digit:]] /tmp/mytest1/
將/etc/issue文件中的內(nèi)容轉(zhuǎn)換為大寫后保存至/tmp/issue.out文件中
- cat /etc/issue|tr '[:lower:]' [:upper:] >> /tmp/issue.out
請總結(jié)描述用戶和組管理類命令的使用方法并完成以下練習(xí):
創(chuàng)建組distro,其GID為2019
[root@centos7 ~]#groupadd -g 2019 distrp
[root@centos7 ~]#cat /etc/group|tail -1
distrp:x:2019:創(chuàng)建用戶mandriva, 其ID號為1005;基本組為distro
[root@centos7 ~]#useradd -u 1005 -g distrp mandriva
[root@centos7 ~]#id mandriva
uid=1005(mandriva) gid=2019(distrp) groups=2019(distrp)創(chuàng)建用戶mageia,其ID號為1100,家目錄為/home/linux
[root@centos7 ~]#useradd -u 1100 -d /home/linux mageia
[root@centos7 ~]#id mageia
uid=1100(mageia) gid=1100(mageia) groups=1100(mageia)給用戶mageia添加密碼,密碼為mageedu,并設(shè)置用戶密碼7天后過期
[root@centos7 ~]#echo magedu |passwd --stdin mageia
Changing password for user mageia.
passwd: all authentication tokens updated successfully.
[root@centos7 ~]#passwd -x 7 mageia
Adjusting aging data for user mageia.
passwd: Success刪除mandriva,但保留其家目錄
[root@centos7 ~]#userdel mageia
[root@centos7 ~]#ls /home
li linux mandriva創(chuàng)建用戶slackware,其ID號為2002,基本組為distro,附加組peguin
[root@centos7 ~]#groupadd peguin
[root@centos7 ~]#groupadd distro
[root@centos7 ~]#useradd -u 2002 -g distro -G peguin slackware
[root@centos7 ~]#id slackware
uid=2002(slackware) gid=2021(distro) groups=2021(distro),2020(peguin)修改slackware的默認(rèn)shell為/bin/tcsh
[root@centos7 ~]#usermod -s /bin/tcsh slackware
[root@centos7 ~]#cat /etc/passwd | tail -1
slackware:x:2002:2021::/home/slackware:/bin/tcsh為用戶slackware新增附加組admins
[root@centos7 ~]#groupadd admins
[root@centos7 ~]#id slackware
uid=2002(slackware) gid=2021(distro) groups=2021(distro),2020(peguin)
[root@centos7 ~]#usermod -aG admins slackware
[root@centos7 ~]#id slackware
uid=2002(slackware) gid=2021(distro) groups=2021(distro),2020(peguin),2022(admins)