centos8环境基本优化
1.防火墙优化
参考链接
https://www.cnblogs.com/zttong/p/17511695.html
| systemctl stop firewalld && systemctl disable firewalld |
| cat /etc/selinux/config |
| setenforce 0 && sed -i 's/SELINUX=permissive/SELINUX=disabled/g' /etc/selinux/config |
2.源优化:
方案1.更换阿里源
| cd /etc/yum.repos.d/ |
| sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-* |
| sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-* |
| yum makecache |
| 安装epel源 |
| dnf install epel-release -y |
方案2.使用centos8.5 源
| [root@models yum.repos.d] |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| [base] |
| name=CentOS-8.5.2111 - Base - mirrors.aliyun.com |
| baseurl=http://mirrors.aliyun.com/centos-vault/8.5.2111/BaseOS/$basearch/os/ |
| gpgcheck=0 |
| gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official |
| |
| |
| [extras] |
| name=CentOS-8.5.2111 - Extras - mirrors.aliyun.com |
| baseurl=http://mirrors.aliyun.com/centos-vault/8.5.2111/extras/$basearch/os/ |
| gpgcheck=0 |
| gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official |
| |
| |
| [centosplus] |
| name=CentOS-8.5.2111 - Plus - mirrors.aliyun.com |
| baseurl=http://mirrors.aliyun.com/centos-vault/8.5.2111/centosplus/$basearch/os/ |
| gpgcheck=0 |
| enabled=0 |
| gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official |
| |
| [PowerTools] |
| name=CentOS-8.5.2111 - PowerTools - mirrors.aliyun.com |
| baseurl=http://mirrors.aliyun.com/centos-vault/8.5.2111/PowerTools/$basearch/os/ |
| gpgcheck=0 |
| enabled=0 |
| gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official |
| |
| |
| [AppStream] |
| name=CentOS-8.5.2111 - AppStream - mirrors.aliyun.com |
| baseurl=http://mirrors.aliyun.com/centos-vault/8.5.2111/AppStream/$basearch/os/ |
| gpgcheck=0 |
| gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official |
| |
安装epel源
| dnf install epel-release -y |
3.ssh连接慢解决
| ll /etc/ssh/sshd_config |
| vim /etc/ssh/sshd_config |
| GSSAPIAuthentication no |
| UseDNS no |
| |
| [root@oldboy-muban ~] |
| /etc/ssh/sshd_config |
| GSSAPIAuthentication no |
| UseDNS no |
| systemctl restart sshd 未来连接速度就很快 |
4.关闭公网,只开放内网(可选)
| [root@huge-muban ~] |
| |
| Removed symlink /etc/systemd/system/multi |
| user.target.wants/NetworkManager.service. |
| Removed symlink /etc/systemd/system/dbus |
| org.freedesktop.nm-dispatcher.service. |
| Removed symlink /etc/systemd/system/network |
| online.target.wants/NetworkManager-wait-online.service. |
| [root@huge-muban ~] |
5.配置定时任务,时间同步
centos7 ntpd
| crontab -e |
| |
| |
| |
| */2 * * * * /sbin/ntpdate ntp1.aliyun.com &>/dev/null |
centos8
| [root@models yum.repos.d] |
| chrony-3.5-1.el8.x86_64 |
| dnf install chrony -y |
6.PS1
| PS1 控制命令行格式 |
| man bash 搜索PS1 |
| vim /etc/profile 最后一行写入 |
| export PS1='[\[\e[34;1m\]\u@\[\e[0m\]\[\e[32;1m\]\H\[\e[0m\] \[\e[31;1m\]\w\[\e[0m\]]\\$ ' |
| [root@huge-muban ~] |
| export PS1='[\[\e[34;1m\]\u@\[\e[0m\]\[\e[32;1m\]\H\ |
| [\e[0m\] \[\e[31;1m\]\w\[\e[0m\]]\\$ ' |
| [root@huge-muban ~] |
| |
| [故障集合]Linux必备故障及原因50个 |
| https://www.jianshu.com/p/99ec5bb4183f |
7.配置sudo
| [root@huge-muban ~]$ grep wheel /etc/sudoers |
| |
| %wheel ALL=(ALL) ALL |
| |
| [root@oldboy-muban ~]$ id huge |
| uid=1000(hueg) gid=1000(huge) |
| groups=1000(huge),10(wheel) |
| 想要配置可以这么操作 |
| huge ALL=(ALL) NOPASSWD: ALL |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 【自荐】一款简洁、开源的在线白板工具 Drawnix