Third weeks

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

[root@centos7 ~]#echo `grep -v -c  '/sbin/nologin' \
/etc/passwd` `grep -v  '/sbin/nologin'\
 /etc/passwd |cut -d: -f1`

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

[09:01:27 root@centos7 ~]#sort -t: -k3 -n \
/etc/passwd |tail -1|cut -d: -f1,3,7
结果
nfsnobody:65534:/sbin/nologin

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

[09:27:22 root@centos7 ~]#netstat -atunl | grep "ESTABLISHED" \
 |tr -s " "|tr " " ":"|cut -d: -f3,4|uniq -c|sort -nr

方法二:

[09:30:41 root@centos7 ~]#ss -atun | grep ESTAB | tr -s " " \
 | cut -d " " -f 5 | cut -d : -f 1 | uniq -c | sort -nr

方法三:

[09:30:46 root@centos7 ~]#w -h | tr -s " " | cut -d " " \
 -f 3 | uniq -c | sort -nr

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

#!/bin/bash
echo "disk use max :`df -h|grep ^/dev/[svm]d |tr -s " " "%"| \
cut -d% -f5|sort -rn|head -n1`"

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

#!/bin/bash

RED="\E[1;31m"
GREEN="echo -e \E[1;32m"
END="\E[0m"

$GREEN---------------------------------Host systeminfo-------------------------$END
echo -e  "HOSTNAME:      $RED`hostname`$END"
echo -e  "IPADDR:        $RED`hostname -I`$END"
echo -e  "OSVERSION:     $RED`cat /etc/redhat-release`$END"
echo -e  "KERNEL:        $RED`uname -r`$END"
echo -e  "CPU:           $RED`lscpu|grep 'Model name' | tr -s ' '|cut -d : -f2`$END"
echo -e    "MEMORY:      $RED`free -h|grep Mem|tr -s ' ': |cut -d " " -f2`$END"
echo -e    "DISK:             $RED`lsblk |grep '^v' |tr -s ' ' |cut -d " " -f4`$END"
$GREEN-------------------------------------------------------------------------$END

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值