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

      

[root@VM-16-11-centos test]# cat /etc/passwd | grep -v /sbin/nologin | wc -l

12

[root@VM-16-11-centos test]# cat /etc/passwd | grep -v /sbin/nologin | cut -d: -f 1

root

sync

shutdown

halt

syslog

lighthouse

test

mandriva

mageia

user1

user2

user3

[root@VM-16-11-centos test]#

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

      

[root@VM-16-11-centos test]# cat /etc/passwd | cut -d: -f 1,3,7 | sort -t: -k2 -rn | head -1

user3:2005:/bin/bash

[root@VM-16-11-centos test]# cat /etc/passwd | cut -d: -f 1,3,7 | sort -t: -k2 -n | tail -n 1

user3:2005:/bin/bash

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

[root@VM-16-11-centos test]# netstat -nt |grep '[0-9]'|tr -s " " :|cut -d: -f6|sort | uniq -c |sort -nr

2 114.242.26.45

1 169.254.0.4

1 169.254.0.138

1 109.244.198.9

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

      

[root@VM-16-11-centos test]#

[root@VM-16-11-centos test]# vim disk.sh

[root@VM-16-11-centos test]#

[root@VM-16-11-centos test]# pwd

/data/test

[root@VM-16-11-centos test]# ls

a1.sh a2.sh a3.sh a4.sh disk.sh

[root@VM-16-11-centos test]# ./disk.sh

-bash: ./disk.sh: Permission denied

[root@VM-16-11-centos test]# ll

total 4

-rw-r--r-- 1 root root 0 Jan 4 15:45 a1.sh

-rw-r--r-- 1 root root 0 Jan 4 15:45 a2.sh

-rw-r--r-t 1 root root 0 Jan 4 15:45 a3.sh

-rw-r--r-t 1 root root 0 Jan 4 15:45 a4.sh

-rw-r--r-- 1 root root 82 Jan 4 17:38 disk.sh

[root@VM-16-11-centos test]# chmod u+x disk.sh

[root@VM-16-11-centos test]# ./disk.sh

5

[root@VM-16-11-centos test]# cat disk.sh

#!/bin/bash

df | tr -s " " % | cut -d% -f5 | grep '[0-9]' | sort -nr | head -n 1



[root@VM-16-11-centos test]#

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

[root@VM-16-11-centos test]# ./systeminfo.sh 

hostname 主机名 : VM-16-11-centos

IPv4 address IPv4地址 : 10.0.16.11

OS version 操作系统版本 : CentOS Linux release 7.6.1810 (Core)

KernelVersion 内核版本: 3.10.0-1160.45.1.el7.x86_64

CPU型号: Intel(R) Xeon(R) Gold 6133 CPU @ 2.50GHz

Memery 内存大小 : MemTotal: 3880172 kB

Diskspace 硬盘大小: 80G

[root@VM-16-11-centos test]# cat systeminfo.sh

#!/bin/bash

echo -e "hostname 主机名 " : `hostname`

echo -e "IPv4 address IPv4地址 :" `ifconfig eth0 | grep -Eo '([0-9]{1,3}.){3}[0-9]{1,3}'| head -n1`

echo -e "OS version 操作系统版本 :" `cat /etc/redhat-release`

echo -e "KernelVersion 内核版本:" `uname -r`

echo -e "CPU型号:" `lscpu|grep "^Model name" | tr -s " " | cut -d: -f2`

echo -e "Memery 内存大小 :" `cat /proc/meminfo | grep MemTotal`

echo -e "Diskspace 硬盘大小:" `lsblk | grep -E '^vda' | grep -Eo [0-9]+[[:upper:]]`

[root@VM-16-11-centos test]#

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