第三周作业

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

[root@Rocky8-mini test]# grep  /sbin/nologin$ /etc/passwd | cut -d: -f1,7

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

[root@Rocky8-mini ~]# cat /etc/passwd | cut -d: -f1,3,7  | sort -t: -k2 -n | tail -1
nobody:65534:/sbin/nologin

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

[root@Rocky8-mini test]# ss -tn | tail -n +2 | tr -s " " : | cut -d: -f6 | sort -n | uniq -c

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

[root@Rocky8-mini test]# cat disk.sh
#!/bin/bash
echo "-------- Maximum disk space usage ---------"
echo "usage:      `df -Th | tail -n +2 | tr -s " " % | cut -d% -f6 | sort -rn | head -1`"

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

[root@Rocky8-mini test]# cat system.info
#!/bin/bash
echo "---------------------The system imformation-------------------"
echo "HOSTNAME:            "   `hostname`
echo "IPADDRESS:            "   `ip address show ens33 | grep -Eo " ([0-9]{1,3}\.){3}[0-9]{1,3}" | head -1`
echo "OS_TYPE:              "   ` cat /etc/redhat-release`
echo "KERNEL:               "   ` uname -r`
echo "CPU:                  "   ` lscpu | grep "^Model name" | tr -s " " | cut -d: -f2`
echo "MEMORY_SIZE:          "   ` free -h | grep Mem | tr -s " " : | cut -d: -f2`
echo "DISK_SIZE:            "   ` lsblk |grep '^sd' |tr -s ' ' |cut -d " " -f4`
posted @   wuhaolam  阅读(18)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· DeepSeek 开源周回顾「GitHub 热点速览」
点击右上角即可分享
微信分享提示