以下总结了4种区分CentOS和Ubuntu系统的方法。

1、lsb_release -a

如果是想查看你的Linux系统是Ubuntu还是CentOS,可以使用lsb_release -a命令,lsb_release -a命令可以列出你的Linux系统是哪个Linux发行版,它还可以列出具体是第几个版本。

2、cat /etc/redhat-release && cat /etc/lsb-release

radhat或centos存在:/etc/redhat-release 这个文件【 命令 cat /etc/redhat-release 】

ubuntu存在 : /etc/lsb-release 这个文件 【命令 cat etc/lsb-release 】

3、apt-get && yum

有yum的就是Centos【yum -help】

有apt-get的就是Ubuntu 【apt-get -help】

4、cat /etc/issue

有Ubuntu字样为ubuntu,没有则是centos

一般用cat /etc/redhat-release && cat /etc/lsb-release 即可
参见系统就redhat和debian的

输出系统基本信息(兼容diebian readhat)


echo "主机名称 $(hostname)"
echo "发行版本 $(cat /etc/*-release | grep PRETTY_NAME | cut -d '=' -f 2- | tr -d '"')"
echo "内核版本 $(uname -r)"
echo "系统类型 $(uname -m)"
echo "启动时间 $(who -b | awk '{print $3, $4}')"
echo "运行时间 $(uptime -p)"

简单系统负载

	CPU使用率: 0.8%
  磁盘使用率: 50%
  网络流量: 接收 44032, 发送 8976
  内存使用率: 63.9344%
  
echo "系统负载情况:"
top -bn1 | grep "Cpu(s)" | awk '{usage = 100 - $8} END {print "  CPU使用率: " usage "%"}'; df -h | awk '{if ($NF == "/") print "  磁盘使用率: " $5}'; ifstat | awk '/eth0/ {print "  网络流量: 接收 "$6", 发送 "$8}'; free -h | awk '/Mem/ {print "  内存使用率: " $3/$2 * 100 "%"}'