服务器优化脚本
#!/bin/bash
echo "关闭selinux"
setenforce 0
getenforce
sed -i '7c SELINUX=disabled' /etc/selinux/config
echo "关闭firewalld"
systemctl stop firewalld
systemctl disable firewalld
echo "修改默认YUM源为阿里"
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
echo "安装常用软件"
yum -y install vim tree lrzsz ntpdate net-tools wget
rpm -qa vim tree lrzsz ntpdate net-tools wget
echo "安装epel源"
wget -O /etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-7.repo
echo "安装自动补全命令"
yum -y install bash-completion.noarch bash-completion-extras.noarch
echo "时间同步"
ntpdate ntp1.aliyun.com
hwclock -w
echo "修改文件描述符"
echo "* - nofile 65535" >> /etc/security/limits.conf
echo "关闭NetworkManagewr"
systemctl stop NetworkManager
systemctl disable NetworkManager
echo "修改命令行颜色"
echo "PS1='[\[\e[34;1m\]\u@\[\e[0m\]\[\e[32;1m\]\H\[\e[0m\]\[\e[31;1m\] \W\[\e[0m\]]# '" >> /root/.bashrc
source /root/.bashrc
echo "服务器优化完毕"