第四周作业

1、统计出/etc/passwd文件中其默认shell为非/sbin/nologin的用户个数,并将用户都显示出来
(1)默认shell为非/sbin/nologin的用户个数
[root@centos7 ~]#grep -v '/sbin/nologin' /etc/passwd | wc -l
(2)并将用户显示出来
[root@centos7 ~]#grep -v '/sbin/nologin' /etc/passwd | cut -d: -f1

2、查出用户UID最大值的用户名、UID及shell类型
[root@centos7 ~]#sort -t: -n -k3 /etc/passwd | tail -1 | cut -d: -f1,3,7

3、统计当前连接本机的每个远程主机IP的连接数,并按从大到小排序
[root@centos7 ~]#ss -atun | grep 'ESTAB' | tr -s " " | cut -d" " -f5 | cut -d: -f1 | uniq -c | sort -nr

4、编写脚本disk.sh,显示当前硬盘分区中空间利用率最大的值
vim disk.sh
#!/bin/bash
echo -e "当前硬盘分区中空间利用率最大值为: `df| tr -s ' ' '%'|cut -d% -f5|sort -nr|head -1`"

5、编写脚本 systeminfo.sh,显示当前主机系统信息,包括:主机名,IPv4地址,操作系统版本,内核版本,CPU型号,内存大小,硬盘大小
vim systeminfo.sh
#!/bin/bash
echo -e "主机名: `hostname `"
echo -e "IPv4地址: `ifconfig eth0 | head -2 | grep inet | tr -s ' ' '%' | cut -d% -f3`"
echo -e "操作版本系统: `cat /etc/redhat-release`"
echo -e "内核版本: `uname -r`"
echo -e "CPU型号: `lscpu | grep "Model name" | tr -d ' ' | cut -d: -f2`"
echo -e "内存大小: `cat /proc/meminfo | head -1 | tr -d ' ' | cut -d : -f2`"
echo -e "硬盘大小: `lsblk | grep sda | head -1 | tr -s ' ' '%' | cut -d % -f4`"

6、20分钟内通关vimtutor(可参考https://yyqing.me/post/2017/2017-02-22-vimtutor-chinese-summary 或 https://www.bilibili.com/video/av669762042/)

你可能感兴趣的:(第四周作业)