Linux-系统安装后初始化的配置

1、配置仓库

gzip /etc/yum.repos.d/*
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
curl -o /etc/yum.repos.d/epel-7.repo http://mirrors.aliyun.com/repo/epel-7.repo
yum clean all
yum makecache

2、安装基本的工具

yum install net-tools vim tree htop iftop \
iotop lrzsz sl wget unzip telnet nmap nc psmisc tcpdump \
dos2unix bash-completion bash-completion-extras sysstat ntpdate \
rsync nfs-utils httpd-tools -y

3、关闭防火墙和SELinux

sed -i '/^SELINUX=/c SELINUX=disabled' /etc/selinux/config && setenforce 0
systemctl disable firewalld
systemctl stop firewalld

systemctl stop NetworkManager
systemctl disable NetworkManager

4、配置时间和时区

timedatectl set-timezone Asia/Shanghai
#增加计划任务
cat >>/var/spool/cron/root <<EOF
#ntp Server update
*/5 * * * * /usr/sbin/ntpdate ntp5.aliyun.com  2>&1 > /dev/null
#ntp end
EOF
ntpdate ntp5.aliyun.com

5、优化

# 设置文件打开数
echo '* - nofile 65535' >> /etc/security/limits.conf

# sshd关闭dns解析
sed -i '/#UseDNS yes/c UseDNS no'  /etc/ssh/sshd_config && systemctl restart sshd

 

posted @ 2023-04-26 09:56  小粉优化大师  阅读(108)  评论(0)    收藏  举报