0
点赞
收藏
分享

微信扫一扫

CentOS 7 系统优化脚本

大明宫 2022-11-16 阅读 168


#!/bin/bash


# set yum
yum install wget -y &>/dev/null

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

mv /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo.backup
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

yum clean all
yum makecache

# time update
yum install ntp ntpdate -y
echo "0 0 * * * /usr/sbin/ntpdate cn.pool.ntp.org" >> /var/spool/cron/root
systemctl restart crond

# other
yum install net-tools telnet nmap vim -y

# vi setting
cat >> /etc/vimrc << EOF
set tabstop=4
set shiftwidth=4
set autoindent
syntax off
EOF

# open file
ulimit -SHn 65535
cat >> /etc/security/limits.conf << EOF
* soft nofile 65535
* hard nofile 65535
* soft nproc 65535
* hard nproc 65535
EOF


# close SELINUX
sed -i '/^SELINUX=/cSELINUX=disabled' /etc/selinux/config
setenforce 0


# install iptables
systemctl stop firewalld
systemctl disable firewalld
yum install iptables-services -y
systemctl start iptables
systemctl enable iptables

 

举报

相关推荐

0 条评论