1、统计出/etc/passwd文件中其默认shell为非/sbin/nologin的用户个数,并将用户都显示出来

grep -v '/sbin/nologin$' /etc/passwd|wc -l

grep -v '/sbin/nologin$' /etc/passwd |cut -d: -f1


2、查出用户UID最大值的用户名、UID及shell类型

getent passwd |sort -t: -k3 -nr|head -n1|cut -d: -f1,3,7


3、统计当前连接本机的每个远程主机IP的连接数,并按从大到小排序

ss -nt4|tr -s ' '|cut -d' ' -f5|sed -nr 's#([0-9]+):[0-9]+#\1#p'|uniq -c |sort -nr

ss -nt4|tr -s ' '|cut -d' ' -f5|grep -Eo '([0-9]{1,3}\.){3}[0-9]{1,3}'|uniq -c |sort -nr

4、编写脚本disk.sh,显示当前硬盘分区中空间利用率最大的值

df|grep '^/dev/sd'|grep -Eo '[0-9]+%'|tr -d %|sort -nr|head -n1

df|grep '^/dev/sd'|sed -nE 's#.* ([0-9]+).*#\1#p'|sort -nr|head -n1

5、编写脚本 systeminfo.sh,显示当前主机系统信息,包括:主机名,IPv4地址,操作系统版本,内核版本,CPU型号,内存大小,硬盘大小

#!/bin/bash

color="\E[1;$[$RANDOM%7+31]m"

end='\E[0m'


echo -e ${color}-----------------Host systeminfo-----------------${end}

echo -e "HOSTNAME: ${color}`hostname`${end}"

echo -e "KERNEL: ${color}`uname -r`${end}"

echo -e "CPU: ${color}`lscpu|grep '^Model name'|tr -s ' '|cut -d: -f 2`${end}"

echo -e "MEMORY: ${color}`free -h|grep Mem|tr -s ' '|cut -d' ' -f 2`${end}"

echo -e "DISK: ${color}`lsblk|grep '^sd'|tr -s ' '|cut -d' ' -f4`${end}"

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