查看Centos系统版本基础信息与防火墙、SElinux
我记得我刚学linux时,安装一个服务一直起不来,我就找同事帮忙,找半天最后发现是SElinux没有关,这种低级错误,在我同事看来简直乐死了,哈哈,所以我写了一个脚本,避免大家在学习时避免这个低级错误,未来我还会创作更多的脚本,欢迎使用测试
#!/bin/bash
echo -e "\e[1;33m系统信息:\e[0m"
echo -e " host name is: \e[1;32m`hostname`\e[0m"
echo -e " ip is : \e[1;32m`ifconfig | grep -Eo '([0-9]{1,3}\.){3}[0-9]{1,3}' | head -n1`\e[0m"
echo -e " os version is : \e[1;32m`cat /etc/centos-release`\e[0m"
echo -e " Kernel version is : \e[1;32m`uname -r`\e[0m"
echo -e " cpu type is : \e[1;32m`lscpu |grep 'Model name' |tr -s ' ' |cut -d : -f2`\e[0m"
echo -e " RAM is : \e[1;32m`free -h | grep 'Mem' | tr -s ' '|cut -d ':' -f2 | cut -d ' ' -f2`\e[0m"
echo -e " Hard Disk SZIE is : \e[1;32m`lsblk |grep 'sda' |head -n1 |tr -s ' ' |cut -d ' ' -f4`\e[0m"
echo -e " time is : \e[1;32m`date +%Y'年'%m'月'%d'日'%H'时'%M'分'%S'秒'`\e[0m"
echo -e " time zone is : \e[1;32m`date +'%Z%z'`\e[0m"
FIREW=`systemctl status firewalld | grep 'active' |tr -s ' '|cut -d ' ' -f3`
if [ $FIREW = active ] ; then
echo -e " firewalld is :\e[1;32mrunning\e[0m"
else
echo -e " firewalld is :\e[1;32mnot running\e[0m"
fi
FIREWSE=`getenforce`
if [ $FIREWSE = Disabled ] ; then
echo -e " SELinux is :\e[1;32mDisabled\e[0m"
else
echo -e " SELinux is :\e[1;32menforcing\e[0m"
fi
脚本下载链接如下
本内容需要登录后才能查看
共有 0 条评论