1.在跟下创建一个目录ceshi,在测试目录下创建一个user目录,将/etc/passwd和/etc/shadow文件复制到/ceshi/user目录中,给/ceshi/user/passwd文件创建一个硬连接文件为passwd.bak。给/ceshi/user/shadow文件创建一个软链接sh.link。
[root@localhost /]# mkdir ceshi
[root@localhost /]# cd ceshi
[root@localhost ceshi]# mkdir user
[root@localhost ceshi]# cd user
[root@localhost user]# mv /etc/passwd . 将/etc/passwd移动到当前目录
[root@localhost user]# mv /etc/shadow . 将/etc/shadow移动到当前目录
[root@localhost user]# ln /ceshi/user/passwd passwd.bak 创建硬链接
[root@localhost user]# ll
total 12
-rw-r--r--. 2 root root 2664 May 8 01:34 passwd
-rw-r--r--. 2 root root 2664 May 8 01:34 passwd.bak
----------. 1 root root 1361 May 8 01:34 shadow
[root@localhost user]# ln -s ceshi/user/shadow sh.link 创建软连接
[root@localhost user]# ll
total 12
-rw-r--r--. 2 root root 2664 May 8 01:34 passwd
-rw-r--r--. 2 root root 2664 May 8 01:34 passwd.bak
----------. 1 root root 1361 May 8 01:34 shadow
lrwxrwxrwx. 1 root root 17 May 8 01:48 sh.link -> ceshi/user/shadow
2.将/etc/ssh/shhd_config文件复制到/etc目录中并重命名为shhd。
[root@localhost user]# cd /ceshi
[root@localhost ceshi]# ll
total 8
-rw-------. 1 root root 4425 May 8 01:50 sshd_config
drwxr-xr-x. 2 root root 67 May 8 01:48 user
[root@localhost ceshi]# mv /ceshi/sshd_config sshd
[root@localhost ceshi]# ll
total 8
-rw-------. 1 root root 4425 May 8 01:50 sshd
drwxr-xr-x. 2 root root 67 May 8 01:48 user
3.找出文件名为passwd的文件并将找出的结果写入/passwd.txt文件中。
[root@localhost ceshi]# find / -name passwd | tee /passwd.txt
find: ‘/run/user/1000/gvfs’: Permission denied
/sys/fs/selinux/class/passwd
/sys/fs/selinux/class/passwd/perms/passwd
/etc/pam.d/passwd
/etc/passwd
/var/lib/sss/mc/passwd
/usr/bin/passwd
/usr/share/licenses/passwd
/usr/share/doc/passwd
/usr/share/bash-completion/completions/passwd
/ceshi/user/passwd
[root@localhost ceshi]# cat /passwd.txt
/sys/fs/selinux/class/passwd
/sys/fs/selinux/class/passwd/perms/passwd
/etc/pam.d/passwd
/etc/passwd
/var/lib/sss/mc/passwd
/usr/bin/passwd
/usr/share/licenses/passwd
/usr/share/doc/passwd
/usr/share/bash-completion/completions/passwd
/ceshi/user/passwd
4.在root用户的家目录下面创建一个test目录,将/ceshi/sshd文件和/ceshi/user/passwd.bak移动到test目录中。
[root@localhost ceshi]# mkdir /root/test
[root@localhost test]# mv /ceshi/sshd /ceshi/user/passwd.bak .
[root@localhost test]# tree .
.
├── passwd.bak
└── sshd
5.将ceshi目录中的user目录和/root/test/sshd文件打包并以gzip程序压缩至test目录中,并将该压缩文件下载至windows客户端。
[root@localhost test]# tar czvf /root/test/us.tar.gz /ceshi/user /root/test/sshd
tar: Removing leading `/' from member names
/ceshi/user/
/ceshi/user/passwd
tar: Removing leading `/' from hard link targets
/ceshi/user/shadow
/ceshi/user/sh.link
/root/test/sshd
[root@localhost test]# ll
total 16
-rw-r--r--. 2 root root 2664 May 8 01:34 passwd.bak
-rw-------. 1 root root 4425 May 8 01:50 sshd
-rw-r--r--. 1 root root 3766 May 8 02:20 us.tar.gz
找到root家目录下的test目录下的压缩文件就可以下载到客户端
6.将第五题中的压缩文件解压到普通用户的家目录中,从解压文件中找到以b或者c开始的行内容并将其内容写入普通用户夹目录下的file文件中。
[root@localhost test]# tar xvf us.tar.gz -C /home/redhat/
[root@localhost redhat]# grep ^[bc] -r ./* > file
[root@localhost redhat]# ll
drwxr-xr-x. 3 root root 18 May 8 02:27 ceshi
drwxr-xr-x. 2 redhat redhat 6 May 6 23:23 Desktop
drwxr-xr-x. 2 redhat redhat 6 May 6 23:23 Documents
drwxr-xr-x. 2 redhat redhat 6 May 6 23:23 Downloads
-rw-r--r--. 1 root root 793 May 8 02:32 file
drwxr-xr-x. 2 redhat redhat 6 May 6 23:23 Music
drwxr-xr-x. 2 redhat redhat 6 May 6 23:23 Pictures
drwxr-xr-x. 2 redhat redhat 6 May 6 23:23 Public
drwxr-xr-x. 3 root root 18 May 8 02:27 root
drwxr-xr-x. 2 redhat redhat 6 May 6 23:23 Templates
drwxr-xr-x. 2 redhat redhat 6 May 6 23:23 Videos
[root@localhost redhat]# cat file 查看文件内容
./ceshi/user/passwd:bin:x:1:1:bin:/bin:/sbin/nologin
./ceshi/user/passwd:chrony:x:993:988::/var/lib/chrony:/sbin/nologin
./ceshi/user/passwd:clevis:x:983:982:Clevis Decryption Framework unprivileged user:/var/cache/clevis:/sbin/nologin
./ceshi/user/passwd:cockpit-ws:x:982:980:User for cockpit web service:/nonexisting:/sbin/nologin
./ceshi/user/passwd:cockpit-wsinstance:x:981:979:User for cockpit-ws instances:/nonexisting:/sbin/nologin
./ceshi/user/passwd:colord:x:978:976:User for colord:/var/lib/colord:/sbin/nologin
./ceshi/user/shadow:bin:*:18199:0:99999:7:::
./ceshi/user/shadow:chrony:!!:18427::::::
./ceshi/user/shadow:clevis:!!:18427::::::
./ceshi/user/shadow:cockpit-ws:!!:18427::::::
./ceshi/user/shadow:cockpit-wsinstance:!!:18427::::::
./ceshi/user/shadow:colord:!!:18427::::::