删除多余的启动项
1.查看内核程序.rpm -qa | grep kernel2.删除多余的内核.yum erase 内核名称(步骤1中显示的结果中的一条或多条,不是全部 )3.重启系统.注: 1.需要root权限.2.将多余选项的删除,一般选择删除版本比较早的.
#!/bin/bash#This script is used for CentOS7.x system initialization configuration#Set the host name, IP address, turn off selinux, firewall, install common tools#Modify hostnameread -p "Please enter the hostname:" hostnameif [ -z $hostname ]; thenecho "Your hostname has not been modified!"elsehostnamectl set-hostname $hostnameecho 'Your hostname is:'`hostname`fi#Modify host IP addressread -p "Please enter your IP address host:" HOSTIPeth=`ip r | grep default | cut -d ' ' -f 5`snetwork=`ip r | grep link | cut -d ' ' -f 9`if [ -z $HOSTIP ]; thenecho 'Your current IP is:'$snetworkelsenmcli connection modify $eth ipv4.method manual ipv4.addresses ${snetwork%.*}.$HOSTIP/24 ipv4.gateway ${snetwork%.*}.254 ipv4.dns ${snetwork%.*}.254 autoconnect yesnmcli connection up $ethecho 'Your IP address is:'`ip r | grep link | cut -d ' ' -f 9`fi#Close SELinuxif [ $(getenforce) = "Enforcing" ]; thensetenforce 0sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/configecho "Selinux is closed!"fi#Turn off the firewall firewalldsystemctl stop firewalld.service && systemctl disable firewalld.service#Install epel source (Alibaba Cloud)if [ $(curl -sL -w "%{http_code}" "https://mirrors.aliyun.com/" -o /dev/null) -eq 200 ];thenecho "The address is clear, continue to install!!!"rpm -ivh http://mirrors.aliyun.com/epel/epel-release-latest-7.noarch.rpmyum clean allelseecho "The address is not smooth, please check the network!!!"exitfiyum install wget bash-completion psmisc tree net-tools vim dos2unix bind-utils telnet lrzsz sysstat nmap yum-utils device-mapper-persistent-data lvm2 git ntp -yif [ $(date | cut -d ' ' -f 5) == "CST" ]; thenntpdate time.windows.comecho "Your current time is:"`date`elsetimedatectl set-timezone Asia/Shanghaintpdate time.windows.comfiecho "=======================================SystemInfo=================================================="echo 'Your hostname is:'`hostname`echo 'Your current IP is:'`ip r | grep link | cut -d ' ' -f 9`echo 'Your Selinux status is: ' $(getenforce)echo 'Your current time is:'`date`
#!/bin/bash#此脚本用于CentOS7.x系统初始化配置 V1#设置主机名、IP地址,关闭selinux、防火墙,安装常用工具#修改主机名read -p "请输入主机名:" hostnameif [ -z $hostname ]; thenecho "您的主机名未被修改!"elsehostnamectl set-hostname $hostnameecho '您的主机名是:'`hostname`fi#修改主机IP地址read -p "请输入您的IP地址主机:" HOSTIPeth=`ip r | grep default | cut -d ' ' -f 5`if [ -z $HOSTIP ]; thenecho '您的当前IP是:'`ip r | grep link | cut -d ' ' -f 9`elsenmcli connection modify $eth ipv4.method manual ipv4.addresses 10.4.7.$HOSTIP/24 ipv4.gateway 10.4.7.254 ipv4.dns 10.4.7.254 autoconnect yesnmcli connection up $ethecho '您的IP地址是:'`ip r | grep link | cut -d ' ' -f 9`fi#关闭SELinuxif [ $(getenforce) = "Enforcing" ]; thensetenforce 0sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/configecho "Selinux已关闭!"fi#关闭防火墙firewalldsystemctl stop firewalld.service && systemctl disable firewalld.service#安装epel源(阿里云)if [ $(curl -sL -w "%{http_code}" "https://mirrors.aliyun.com/" -o /dev/null) -eq 200 ];thenecho "地址通畅,继续安装!!!"rpm -ivh http://mirrors.aliyun.com/epel/epel-release-latest-7.noarch.rpmdnf clean allelseecho "地址不通畅,请检查网络!!!"exitfiyum install wget bash-completion psmisc tree net-tools vim dos2unix bind-utils telnet lrzsz sysstat nmap yum-utils device-mapper-persistent-data lvm2 git ntp -yif [ $(date | cut -d ' ' -f 5) == "CST" ]; thenntpdate time.windows.comecho "您的目前时间是:"`date`elsetimedatectl set-timezone Asia/Shanghaintpdate time.windows.comfiecho '您的主机名是:'`hostname`echo '您的当前IP是:'`ip r | grep link | cut -d ' ' -f 9`echo $(getenforce)echo '您的当前时间是:'`date`
