Ubuntu更换软件源

国内访问Ubuntu的服务器的速度基本随缘,有时候奇慢无比。一般来说服务器端访问速度是没有问题的,奈何本地也需要使用,如:Ubuntu的PC端,win10的Linux子系统。本地使用,如果还是使用Ubuntu的官方源的话,速度真心感人,这时候就需要修改软件源了。就个人的使用感受来说,阿里巴巴开源镜像站提供的镜像还是很靠谱的,速度基本可以维持在1M/s的水平。

Ubuntu的软件源位于/etc/apt/sources.list,自定义软件源的时候,可以将其存放在/etc/apt/sources.list.d文件夹下。

目前在用的win10的Linux子系统使用的是1804版本的Ubuntu,而阿里巴巴开源镜像站官方正好有这版本的软件源配置说明😂,参见:ubuntu镜像-ubuntu下载地址-ubuntu安装教程-阿里巴巴开源镜像站

创建自己的配置文件,比如创建aliyun.list
bash sudo vi /etc/apt/sources.list.d/aliyun.list

编辑内容如下:
bash 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-proposed main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed 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
然后执行:
bash sudo apt-get update
即可。

现在使用Ubuntu 2004,做如下操作:
备份原来的源文件:

1
cp sources.list sources.list.bak
然后修改源文件,打开/etc/apt/sources.list,粘贴如阿里的源:
1
vi /etc/apt/sources.list
粘贴后保存退出:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse

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

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

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

deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
接着更新源,开始使用:
1
apt update