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