标签:
输出系统信息
#!/bin/bash if [ $# -eq 0 ];then echo "---------------------------------------------------------------------------" # OS Type echo " OS Type: $(uname -o)" # OS Release Version and Name echo "OS Release Version and Name: $(cat /etc/issue | head -n 1)" #Architecture echo " Architecture: $(uname -m)" #Kernel Release echo " Kernel Release: $(uname -r)" #hostname echo " hostname: $HOSTNAME" #Internal IP echo " Internal IP: $(hostname -I)" #External IP echo " External IP: $(curl -s ipecho.net/plain)" #DNS dnsservers="" for i in $(cat /etc/resolv.conf | grep ‘^nameserver‘ | awk ‘{print $NF}‘) do dnsservers="$dnsservers$i " done echo " DNS: $dnsservers" #if connected to Internet or not echo " internet status: $( ping -c 2 www.baidu.com &> /dev/null && echo ‘connected‘ || echo ‘disconnected‘)" echo "---------------------------------------------------------------------------" fi
输出结果:
OS Type: GNU/Linux OS Release Version and Name: CentOS release 6.6 (Final) Architecture: x86_64 Kernel Release: 2.6.32-504.el6.x86_64 hostname: wap Internal IP: 192.168.110.173 External IP: 218.30.109.26 DNS: 218.30.105.51 219.141.140.10 internet status: connected
标签:
原文地址:http://www.cnblogs.com/jackgaolei/p/5145764.html