查询linux系统信息小脚本-适用于centos7
#!/bin/bash
echo -e **************"\033[1;34m"system information"\033[0m"********************
COLOR="\033[1;31m"
END="\033[0m"
echo -e "主机名称: $COLOR`hostname`$END"
echo -e "ipv4地址: $COLOR`ifconfig eth0 |grep -Eo '([0-9]{1,3}\.){3}[0-9]{1,3}'|head -n1`$END"
echo -e "系统版本: $COLOR`cat /etc/redhat-release`$END"
echo -e "内核版本: $COLOR`uname -r`$END"
echo -e "cpu型号: $COLOR`lscpu |grep 'Intel(R)'|tr -s ' ' %|cut -d% -f4`$END"
echo -e "内存容量: $COLOR`free -h |grep 'Mem' |tr -s ' ' : |cut -d: -f2`$END"
echo -e "磁盘容量: $COLOR`lsblk |grep '^sda'|tr -s ' ' : |cut -d: -f5`$END"