运维 第三单元作业

第三单元作业

  • 显示当前时间,显示格式为hh:mm::ss,并保存到文件time.txt

[student@localhost Desktop]$ date +%X |tee time.txt
11:55:15 AM
[student@localhost Desktop]$ cat time.txt
11:55:15 AM

  • 显示/etc/passwd文件的第15—18行内容

[root@localhost Desktop]# wc -l /etc/passwd
38 /etc/passwd
[root@localhost Desktop]# head -n 18 | tail -n 3 /etc/passwd
sshd:x :74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
tcpdump: x:72:72:: /:/sbin/nologin
student: x:1000:1000:student:/home/student:/bin/bash

  • 显示/bin中文件包含大写字母的文件,保存到bin_westos_file.txt文件中,并统计个数显示到屏幕

[student@localhost Desktop]$ find /bin/[[:upper:]] | tee bin_westos_file.txt | wc -l
5

  • 在student 用户下查找/etc 下 passwd文件,屏蔽错误输出

[student@localhost Desktop]$ find /etc/ -name passwd > westos
[student@localhost Desktop]$ cat westos
/etc/passwd
/etc/pam.d/passwd

  • 在student用户下查找/etc 下 passwd文件,正确输出保存到/tmp/westos.out 错误额输出保存到 /tmp/westos.err

[student@localhost Desktop]$ find /etc/ -name passwd >> /tmp/westos.out 2>>/tmp/westos.err
[student@localhost Desktop]$ cat /tmp/westos.out
[student@localhost Desktop]$ cat /tmp/westos.err

  • 在student 用户下查找 /etc下 passwd文件,显示命令输出并保存输出到 /tmp/westos.all

[student@localhost Desktop]$ find /etc/ -name passwd >> /tmp/westos.out 2>>/tmp/westos.err
[student@localhost Desktop]$ cat /tmp/westos.all

猜你喜欢

转载自blog.csdn.net/qq_38840475/article/details/82878854