Ubuntu18.04和CentOS7更换阿里源

本文最后更新于:June 5, 2019 pm

在CentOS7.6和Ubuntu18.04上面更换软件源为阿里源。

1、Ubuntu18.04

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# 首先备份源镜像源
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak

# 接着将源镜像源的内容全部注释掉,更改为下列内容
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse


# 更新镜像源使其生效
sudo apt-get update
sudo apt-get upgrade

2、CentOS7

1
2
3
4
5
6
7
8
9
10
11
# 首先备份源镜像源
cd /etc/yum.repos.d
mv CentOS-Base.repo CentOS-Base.repo.bak

# 下载新镜像源并更改名称
wget http://mirrors.aliyun.com/repo/Centos-7.repo -O CentOS-Base.repo

# 更新镜像源使其生效
yum clean all
yum makecache
yum update