删除多余的启动项

    1. 1.查看内核程序.
    2. rpm -qa | grep kernel
    3. 2.删除多余的内核.
    4. yum erase 内核名称(步骤1中显示的结果中的一条或多条,不是全部 )
    5. 3.重启系统.
    6. 注: 1.需要root权限.
    7. 2.将多余选项的删除,一般选择删除版本比较早的.
    1. #!/bin/bash
    2. #This script is used for CentOS7.x system initialization configuration
    3. #Set the host name, IP address, turn off selinux, firewall, install common tools
    4. #Modify hostname
    5. read -p "Please enter the hostname:" hostname
    6. if [ -z $hostname ]; then
    7. echo "Your hostname has not been modified!"
    8. else
    9. hostnamectl set-hostname $hostname
    10. echo 'Your hostname is:'`hostname`
    11. fi
    12. #Modify host IP address
    13. read -p "Please enter your IP address host:" HOSTIP
    14. eth=`ip r | grep default | cut -d ' ' -f 5`
    15. snetwork=`ip r | grep link | cut -d ' ' -f 9`
    16. if [ -z $HOSTIP ]; then
    17. echo 'Your current IP is:'$snetwork
    18. else
    19. nmcli connection modify $eth ipv4.method manual ipv4.addresses ${snetwork%.*}.$HOSTIP/24 ipv4.gateway ${snetwork%.*}.254 ipv4.dns ${snetwork%.*}.254 autoconnect yes
    20. nmcli connection up $eth
    21. echo 'Your IP address is:'`ip r | grep link | cut -d ' ' -f 9`
    22. fi
    23. #Close SELinux
    24. if [ $(getenforce) = "Enforcing" ]; then
    25. setenforce 0
    26. sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
    27. echo "Selinux is closed!"
    28. fi
    29. #Turn off the firewall firewalld
    30. systemctl stop firewalld.service && systemctl disable firewalld.service
    31. #Install epel source (Alibaba Cloud)
    32. if [ $(curl -sL -w "%{http_code}" "https://mirrors.aliyun.com/" -o /dev/null) -eq 200 ];then
    33. echo "The address is clear, continue to install!!!"
    34. rpm -ivh http://mirrors.aliyun.com/epel/epel-release-latest-7.noarch.rpm
    35. yum clean all
    36. else
    37. echo "The address is not smooth, please check the network!!!"
    38. exit
    39. fi
    40. yum 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 -y
    41. if [ $(date | cut -d ' ' -f 5) == "CST" ]; then
    42. ntpdate time.windows.com
    43. echo "Your current time is:"`date`
    44. else
    45. timedatectl set-timezone Asia/Shanghai
    46. ntpdate time.windows.com
    47. fi
    48. echo "=======================================SystemInfo=================================================="
    49. echo 'Your hostname is:'`hostname`
    50. echo 'Your current IP is:'`ip r | grep link | cut -d ' ' -f 9`
    51. echo 'Your Selinux status is: ' $(getenforce)
    52. echo 'Your current time is:'`date`
    1. #!/bin/bash
    2. #此脚本用于CentOS7.x系统初始化配置 V1
    3. #设置主机名、IP地址,关闭selinux、防火墙,安装常用工具
    4. #修改主机名
    5. read -p "请输入主机名:" hostname
    6. if [ -z $hostname ]; then
    7. echo "您的主机名未被修改!"
    8. else
    9. hostnamectl set-hostname $hostname
    10. echo '您的主机名是:'`hostname`
    11. fi
    12. #修改主机IP地址
    13. read -p "请输入您的IP地址主机:" HOSTIP
    14. eth=`ip r | grep default | cut -d ' ' -f 5`
    15. if [ -z $HOSTIP ]; then
    16. echo '您的当前IP是:'`ip r | grep link | cut -d ' ' -f 9`
    17. else
    18. nmcli 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 yes
    19. nmcli connection up $eth
    20. echo '您的IP地址是:'`ip r | grep link | cut -d ' ' -f 9`
    21. fi
    22. #关闭SELinux
    23. if [ $(getenforce) = "Enforcing" ]; then
    24. setenforce 0
    25. sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
    26. echo "Selinux已关闭!"
    27. fi
    28. #关闭防火墙firewalld
    29. systemctl stop firewalld.service && systemctl disable firewalld.service
    30. #安装epel源(阿里云)
    31. if [ $(curl -sL -w "%{http_code}" "https://mirrors.aliyun.com/" -o /dev/null) -eq 200 ];then
    32. echo "地址通畅,继续安装!!!"
    33. rpm -ivh http://mirrors.aliyun.com/epel/epel-release-latest-7.noarch.rpm
    34. dnf clean all
    35. else
    36. echo "地址不通畅,请检查网络!!!"
    37. exit
    38. fi
    39. yum 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 -y
    40. if [ $(date | cut -d ' ' -f 5) == "CST" ]; then
    41. ntpdate time.windows.com
    42. echo "您的目前时间是:"`date`
    43. else
    44. timedatectl set-timezone Asia/Shanghai
    45. ntpdate time.windows.com
    46. fi
    47. echo '您的主机名是:'`hostname`
    48. echo '您的当前IP是:'`ip r | grep link | cut -d ' ' -f 9`
    49. echo $(getenforce)
    50. echo '您的当前时间是:'`date`