更换Ubuntu国内镜像源

更换Ubuntu国内镜像源:

由于Ubuntu官方软件仓库服务器位于国外,导致我们国内访问体验非常糟糕,下载网速只有200-300k左右,令人泪目。

所以我们需要将系统默认下载地址配置为国内的镜像源,以此提高用户体验。

准备工作:

备份源文件:

cp /etc/apt/sources.list /etc/apt/sources.list.bak

若要恢复文件则:

cp /etc/apt/sources.list.bak /etc/apt/sources.list

编辑源文件:

使用nano编辑器对源文件进行编辑(需要root权限):

nano /etc/apt/sources.list

(使用 # 将原来默认源地址注释掉)

添加源:

deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse  
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse  
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse  
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse 

##测试版源  
deb http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse  

#源码
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse  
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse  
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse  
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse  
#测试版源  
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse  

#Canonical 合作伙伴和附加
deb http://archive.canonical.com/ubuntu/ xenial partner  
deb http://extras.ubuntu.com/ubuntu/ xenial main

(此处使用阿里云的源为例,Ubuntu版本为16.04)

注意:Ubuntu系统根据其版本不同,其系统代号也不同,例如16.04版本其代号为Xenial Xerus,而20.04版本其代号为Focal Fossa,故镜像源参数也有所不同,若你想将上文中针对Ubuntu16.04版本的国内镜像源用于20.04版本,则你需要将代码中 'xenial' 替换为 'Focal' 。

执行更新命令(应用源):

 sudo apt-get update
 sudo apt-get upgrade 

附录:

Ubuntu历史版本:

版本号 代号 发行日期
20.04 LTS Focal Fossa 2020/4/23
18.04 LTS Bionic Beaver 2018/04/26
16.04 LTS Xenial Xerus 2016/04/21
14.04 LTS Trusty Tahr 2014/04/18
原文地址:https://www.cnblogs.com/mikelucis/p/13225647.html