系统源优化
#系统软件源优化
bash <(curl -sSL https://linuxmirrors.cn/main.sh)
#防火墙
sudo ufw disable
sudo ufw status
时间同步
#安装软件
apt install chrony -y
#修改时间同步服务器
vim /etc/chrony/chrony.conf
pool ntp.aliyun.com iburst maxsources 4
#重启服务
systemctl restart chrony.service && systemctl enable chrony.service && systemctl status chrony.service
#设置时区为中国
timedatectl set-timezone 'Asia/Shanghai'
文件句柄优化
echo "fs.file-max = 65535" > /etc/sysctl.conf
sysctl -p
cat > /etc/security/limits.conf <<EOF
* hard nofile 65535
* soft nofile 65535
root hard nofile 65535
root soft nofile 65535
EOF
cat > /etc/systemd/system.conf <<EOF
[Manager]
DefaultLimitCORE=infinity
DefaultLimitNOFILE=65535
DefaultLimitNPROC=65535
EOF
systemctl daemon-reexec
删除相关日志和缓存
#删除apt缓存
rm -rf /var/log/apt/*
rm -rf /var/log/dpkg.log
rm -rf /var/log/aptitude
rm -rf /var/lib/apt/lists/*
#关闭历史命令
sed -i 's/HISTSIZE=.*/HISTSIZE=1000/' ~/.bashrc
sed -i 's/HISTFILESIZE=.*/HISTFILESIZE=0/' ~/.bashrc