显示/etc目录下,以非字母开头,后面跟了一个字母以及其它任意长度任意字符的文件或目录
- ls /etc/[^[:alpha:]]
复制/etc目录下所有以p开头,以非数字结尾的文件或目录到/tmp/mytest1目录中。
- cp -r /etc/p*[^[:digit:]] /tmp/mytest1/
将/etc/issue文件中的内容转换为大写后保存至/tmp/issue.out文件中
- cat /etc/issue|tr '[:lower:]' [:upper:] >> /tmp/issue.out
请总结描述用户和组管理类命令的使用方法并完成以下练习:
创建组distro,其GID为2019
[root@centos7 ~]#groupadd -g 2019 distrp
[root@centos7 ~]#cat /etc/group|tail -1
distrp:x:2019:创建用户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)创建用户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,并设置用户密码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创建用户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的默认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)