1、统计出/etc/passwd文件中其默认shell为非/sbin/nologin的用户个数,并将用户都显示出来
[root@node1 ~]# grep -v "/sbin/nologin" /etc/passwd | wc -l&&grep -v "/sbin/nologin" /etc/passwd | cut -d: -f1
9
root
sync
shutdown
halt
gw
user1
user2
user3
mageia
2、查出用户UID最大值的用户名、UID及shell类型
方法一
[root@node1 scripts]# vim UID.sh
#!/bin/bash
#
let -i max=0
for i in `cat /etc/passwd | cut -d: -f3`;do
    [ $max -gt $i ] && $max=$i
done
grep "$i" /etc/passwd | cut -d: -f1,3,7
[root@node1 scripts]# bash UID.sh
slackware:2002:/sbin/nologin
方法二
[root@node1 ~]# grep `cat /etc/passwd | cut -d: -f3 | sort -rn | head -1`/etc/passwd | cut -d: -f1,3,7
slackware:2002:/sbin/nologin
3、统计当前连接本机的每个远程主机IP的连接数,并按从大到小排序
[root@node1 ~]# netstat -t | grep "ssh" | tr -s ' ' | cut -d' ' -f5 | cut -d: -f1 | sort -rn
192.168.31.214
192.168.31.214
192.168.31.214
192.168.31.214
192.168.31.214
192.168.31.214
4、编写脚本disk.sh,显示当前硬盘分区中空间利用率最大的值
[root@node1 scripts]# vim disk.sh
#!/bin/bash
#
maxvalue=`df -h | tr -s ' ' | cut -d' ' -f5 | sort -rn | head -1`
echo -e "The value of the maximum space utilization in the current hard disk partition is:\033[1;4;32m$maxvalue\033[0m"
[root@node1 scripts]# bash disk.sh
The value of the maximum space utilization in the current hard disk partition is:13%
5、编写脚本 systeminfo.sh,显示当前主机系统信息,包括:主机名,IPv4地址,操作系统版本,内核版本,CPU型号,内存大小,硬盘大小
[root@node1 scripts]# vim systeminfo.sh
#!/bin/bash
#
HOSTNAME=`hostname`
IP=`ip a show ens33 | grep "inet" | grep -v "inet6" | awk '{print $2}' | cut -d'/' -f1`
SYSTEM=`cat /etc/centos-release`
CORE=`uname -r`
CPU=`cat /proc/cpuinfo | grep 'model name' |uniq | cut -d: -f2`
MEMORY=`free -mh | grep -i "mem" | awk '{print$2}'`
DISKNUM=`fdisk -l | grep -i "/dev" | grep -i "disk" | wc -l`
systemname=("HOSTNAME" "IP" "SYSTEM VERSION" "CORE VERSION" "CPU" "MEMORY SIZE")
systeminfo=("$HOSTNAME" "$IP" "$SYSTEM" "$CORE" "$CPU" "$MEMORY")
for s in `seq 1 $DISKNUM`;do
    eval DISK$s=`fdisk -l | grep -i "/dev" | grep -i "disk" | head -$s | tail -1|  awk '{print $2$3$4}' | cut -d',' -f1`
    eval systeminfo[$(($s+5))]='$'DISK$s
    systemname[$(($s+5))]="DISK$s SIZE"
done
for i in ${!systeminfo[*]};do
    echo "--------------------------------------------------------------"
    printf "|%-15s| %-43s|\n" "${systemname[$i]}" "${systeminfo[$i]}"
done
echo "--------------------------------------------------------------"

[root@node1 scripts]# bash systeminfo.sh

--------------------------------------------------------------
|HOSTNAME       | node1                                      |
--------------------------------------------------------------
|IP             | 192.168.31.233                             |
--------------------------------------------------------------
|SYSTEM VERSION | CentOS Linux release 7.9.2009 (Core)       |
--------------------------------------------------------------
|CORE VERSION   | 3.10.0-1160.el7.x86_64                     |
--------------------------------------------------------------
|CPU            |  Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz |
--------------------------------------------------------------
|MEMORY SIZE    | 1.8G                                       |
--------------------------------------------------------------
|DISK1 SIZE     | /dev/sda:107.4GB                           |
--------------------------------------------------------------
|DISK2 SIZE     | /dev/sdb:107.4GB                           |
--------------------------------------------------------------
6、20分钟内通关vimtutor(可参考https://yyqing.me/post/2017/2017-02-22-vimtutor-chinese-summary)
ok