题1
指定目录
/etc
名称要求
以非字母开头,后接一个字母,再接任意字符,如下:
[root@use11 ~]# touch /etc/1t455
[root@use11 ~]# touch /etc/2dd34
[root@use11 ~]# touch /etc/22d34
[root@use11 ~]# ls /etc/ | grep '^[^a-zA-Z]\{1\}[[:alpha:]]\{1\}.*'
1t455
2dd34
题2
要求:
复制/etc下,开头为p,结尾为非数字的文件,到/tmp/mytest1下,如下:
[root@use11 ~]# mkdir /tmp/mytest1
[root@use11 ~]# cp -a /etc/p*[^0-9] /tmp/mytest1/
[root@use11 ~]# ls /tmp/mytest1/
pam.d passwd passwd- pki plymouth pm popt.d postfix ppp prelink.conf.d printcap profile profile.d protocols python
题3
将/etc/issue内容转换为大写保存到/tmp/issue.out
[root@use10 ~]# cat /etc/issue
\S
Kernel \r on an \m
[root@use10 ~]# cat /etc/issue | tr 'a-z' 'A-Z' > /tmp/issue.out
[root@use10 ~]# cat /tmp/issue.out
\S
KERNEL \R ON AN \M
题4
创建组,并指定GID
[root@use10 ~]# groupadd -g 2019 distro
创建用户,指定UID和GID
[root@use10 ~]# useradd -u 1005 -g distro mandriva
创建用户,指定UID和家目录
useradd -u 1100 -d /home/linux mageia
添加用户密码,指定账号过期时间
[root@use10 ~]# echo 'mageedu' | passwd --stdin mageia
Changing password for user mageia.
passwd: all authentication tokens updated successfully.
[root@use10 ~]# passwd -x 7 mageia
Adjusting aging data for user mageia.
passwd: Success
删除用户但不删除家目录
[root@use10 ~]# userdel mandriva
[root@use10 ~]# ls /home/
linux mandriva
创建用户,指定UID,基本组与附加组
[root@use10 ~]# groupadd peguin
[root@use10 ~]# useradd -u 2002 -g distro -G peguin slackware
[root@use10 ~]# id slackware
uid=2002(slackware) gid=2019(distro) groups=2019(distro),2020(peguin)
修改账号的默认shell类型
[root@use10 ~]# tail -n 1 /etc/passwd
slackware:x:2002:2019::/home/slackware:/bin/tcsh
增加账号的附加组
[root@use10 ~]# groupadd admins
[root@use10 ~]# usermod -a -G admins slackware
[root@use10 ~]# id slackware
uid=2002(slackware) gid=2019(distro) groups=2019(distro),2020(peguin),2021(admins)