[root@centos7 ~]# echo "一共`cat /etc/passwd |grep -v ‘/sbin/nologin‘ | wc -l`个,分别是:";cat /etc/passwd |grep -v ‘/sbin/nologin‘ |cut -d: -f1
一共5个,分别是:
root
sync
shutdown
halt
chen
[root@centos7 ~]# cat /etc/passwd |cut -d: -f1,3,7 |sort -t: -k2 -nr |head -n1
nfsnobody:65534:/sbin/nologin
或者
[root@centos7 ~]# cat /etc/passwd |cut -d: -f1,3,7 |sort -t: -k2 -n |tail -n1
nfsnobody:65534:/sbin/nologin
[root@centos7 ~]# ss -atun |grep ‘ESTAB‘ |tr -s " " |cut -d" " -f5 |cut -d: -f1 |uniq -c |sort -nr
1 192.168.150.128
[root@centos7 ~]# vim disk.sh
#!/bin/bash
#
diskmaxused=`df -h |grep ‘^/dev/sd‘ |tr -s ‘ ‘ % |cut -d% -f5 | sort -nr |head -n1`
echo "当前硬盘分区中空间利用率最大的值:$diskmaxused"
[root@centos7 ~]# sh disk.sh
当前硬盘分区中空间利用率最大的值:15
#!/bin/bash
#
echo "----------当前主机系统信息----------"
echo "主机名: `hostname`"
echo "IPV4地址: `hostname -I`"
echo "操作系统版本: `cat /etc/redhat-release`"
echo "内核版本: `uname -r`"
echo "CPU型号: `lscpu |grep ‘Model name‘ |tr -s ‘ ‘ |cut -d: -f2`"
echo "内存大小为: `free -h |grep Mem |tr -s ‘ ‘ : |cut -d: -f2`"
echo "硬盘大小为: `lsblk |grep ‘^sd‘ |tr -s ‘ ‘ |cut -d‘ ‘ -f4`"
[root@centos7 ~]# sh systeminfo.sh
----------当前主机系统信息----------
主机名: centos7.blaine.com
IPV4地址: 192.168.150.128
操作系统版本: CentOS Linux release 7.6.1810 (Core)
内核版本: 3.10.0-957.el7.x86_64
CPU型号: AMD Ryzen 5 5600X 6-Core Processor
内存大小为: 1.8G
硬盘大小为: 200G
原文:https://www.cnblogs.com/blaine/p/14497390.html