linux基礎(chǔ)系統(tǒng)優(yōu)化

1.配置yum源

1、備份

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

2、下載新的CentOS-Base.repo 到/etc/yum.repos.d/

curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

3、之后運(yùn)行yum makecache生成緩存
4、查看源列表yum repolist

[root@docker ~]# yum repolist 
已加載插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
源標(biāo)識(shí)              源名稱                                     狀態(tài)
base/7/x86_64       CentOS-7 - Base - mirrors.aliyun.com       10,019
extras/7/x86_64     CentOS-7 - Extras - mirrors.aliyun.com        419
updates/7/x86_64    CentOS-7 - Updates - mirrors.aliyun.com     2,146
repolist: 12,584

2.配置epel

1、備份(如有配置其他epel源)

mv /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo.backup
mv /etc/yum.repos.d/epel-testing.repo /etc/yum.repos.d/epel-testing.repo.backup

2、下載新repo 到/etc/yum.repos.d/

curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

3.安裝常用工具軟件命令

yum install -y tree vim bash-completion* wget lsof nc nmap lrzsz telnet psmisc bind-utils net-tools

4.關(guān)閉selinux和防火墻

關(guān)閉selinux

[root@wsm ~]# vim /etc/selinux/config 
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled                         #修改為disabled
# SELINUXTYPE= can take one of three two values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected proces
ses are protected. 
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

或者執(zhí)行setenforce 0

關(guān)閉防火墻

[root@wsm ~]# systemctl stop firewalld NetworkManager
[root@wsm ~]# systemctl disable firewalld NetworkManager
Removed symlink /etc/systemd/system/multi-user.target.wants/NetworkManager.service.
Removed symlink /etc/systemd/system/dbus-org.freedesktop.NetworkManager.service.
Removed symlink /etc/systemd/system/dbus-org.freedesktop.nm-dispatcher.service.
[root@wsm ~]# systemctl is-active firewalld NetworkManager
unknown
inactive
[root@wsm ~]# systemctl is-enabled firewalld NetworkManager
disabled
disabled

5.優(yōu)化ssh

修改ssh配置文件

[root@wsm ~]# vim /etc/ssh/sshd_config 

UseDNS yes 改為 UseDNS no
GSSAPIAuthentication yes 改為 GSSAPIAuthentication no

修改完成,重啟服務(wù)

[root@wsm ~]# systemctl restart sshd

6.時(shí)間同步

crontab -e
####每隔五分鐘同步時(shí)間
* */5 * * * sh ntpdate ntp1.aliyum.com >/dev/null 2>&1
###注意要提前安裝ntpdate命令

腳本

#!/bin/bash
#linux基礎(chǔ)優(yōu)化自動(dòng)執(zhí)行腳本
#作者:wsm
#時(shí)間:2019-7-10


#優(yōu)化yum源,改為國(guó)內(nèi)阿里源及配置epel源
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 http://mirrors.aliyun.com/repo/Centos-7.repo &&
\curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
#安裝常用工具及軟件
yum install -y tree vim bash-completion* wget lsof nc nmap lrzsz telnet psmisc bind-utils net-tools
#關(guān)閉selinux和防火墻
sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config && setenforce 0
systemctl stop firewalld NetworkManager
systemctl disable firewalld NetworkManager
#優(yōu)化ssh
sed -i 's#GSSAPIAuthentication yes#GSSAPIAuthentication no#g' /etc/ssh/sshd_config
sed -i 's#UseDNS yes#UseDNS no#g' /etc/ssh/sshd_config
systemctl restart sshd
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容