[root@ct7 ~]# grep -vc "/sbin/nologin" /etc/passwd
[root@ct7 ~]# grep -v "/sbin/nologin" /etc/passwd | cut -d: -f 1
[root@ct7 ~]# cat /etc/passwd | sort -t: -k3 -n | tail -1 | cut -d: -f1,3,7
[root@ct7 ~]# w -h | tr -s " "| cut -d " " -f3 | sort | uniq -c | sort -nr
`#!/bin/bash
#!/bin/bash #显示当前硬盘分区中空间利用率最大的值 max_disk=`df -h | tr -s " " | cut -d " " -f5 | sort -nr | head -1` echo "当前硬盘分区中空间利用率最大的值: ${max_disk}"
#!/bin/bash # 编写脚本 systeminfo.sh,显示当前主机系统信息,包括:主机名,IPv4地址,操作系统版本,内核版本,CPU型号,内存大小,硬盘大小 echo "主机名: `hostname`" echo "IPv4地址:`ip addr show eth0 | grep -Eo '([0-9]{1,3}\.){3}[0-9]{1,3}' | head -1`" echo "系统版本:`cat /etc/centos-release`" echo "内核版本:`uname -r`" echo "CPU型号: `lscpu | grep -i "model name" | cut -d: -f2 | tr -s " "`" echo "内存大小:`free -h | grep Mem | tr -s " " ":" | cut -d: -f2` " echo "硬盘大小:`lsblk | grep 'sda\>' | tr -s " " | cut -d " " -f4`"