1、查看/etc/passwd文件的第18-20行内容,并将找到的内容存储至/home/passwd文件中(head,tail,>,>>)
[root@localhost ~]# touch /home/passwd
[root@localhost ~]# head -20 /etc/passwd | tail -3
tss:x:59:59:Account used for TPM access:/dev/null:/sbin/nologin
colord:x:997:993:User for colord:/var/lib/colord:/sbin/nologin
clevis:x:996:992:Clevis Decryption Framework unprivileged user:/var/cache/clevis:/usr/sbin/nologin
[root@localhost ~]# head -20 /etc/passwd | tail -3 > /home/passwd
[root@localhost ~]# cat /home/passwd
tss:x:59:59:Account used for TPM access:/dev/null:/sbin/nologin
colord:x:997:993:User for colord:/var/lib/colord:/sbin/nologin
clevis:x:996:992:Clevis Decryption Framework unprivileged user:/var/cache/clevis:/usr/sbin/nologin
[root@localhost ~]#
2、查找/etc/passwd文件中包含root字符的行并将找到的行存储至/root/passwd文件中(grep,>,>>)
[root@localhost ~]# touch /root/passwd
[root@localhost ~]# grep root /etc/passwd
root:x:0:0:root:/root:/bin/bash
operator:x:11:0:operator:/root:/sbin/nologin
[root@localhost ~]# grep root /etc/passwd > /root/passwd
[root@localhost ~]# cat /root/passwd
root:x:0:0:root:/root:/bin/bash
operator:x:11:0:operator:/root:/sbin/nologin
[root@localhost ~]#
3、将/home目录复制到/root目录(cp -r)
4、将/root/home目录,/home/passwd和/root/passwd打包并压缩为/root/hp.tar.xz(tar -cJf)
5、创建组admin-group,添加用户admin属于admin-group组(groupadd,useradd -g -G)
6、为admin账号设置密码为123(passwd)