ubuntu替换阿里源

---------------------------------------------------------

参考文章:https://www.jianshu.com/p/97c35d569aa3

---------------------------------------------------------

因为Ubuntu自带的源服务器在国外,下载和更新软件的时候速度很慢,不稳定,所以需要将源更新为国内的源。国内的源比较多,常用的就是阿里的源。

1.备份原有源文件,方便在替换出问题时回滚

sudo cp /etc/apt/sources.list /etc/apt/source.list.bk

2.更改sources.list文件

vim /etc/apt/sources.list

替换里面的内容为

# 阿里源
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb 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 main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse  

这里需要注意的是不同的ubuntu发行版本对应的源也是不一样的,主要的区别在版本号

Ubuntu 12.04 (LTS)代号为precise。

Ubuntu 14.04 (LTS)代号为trusty。

Ubuntu 15.04 代号为vivid。

Ubuntu 15.10 代号为wily。

Ubuntu 16.04 (LTS)代号为xenial。

Ubuntu 18.04 (LTS)代号为bionic。

目前我的版本是18.04所以里面的版本号是bionic,如果是其他版本号直接替换里面的版本编号即可。

查看自己ubuntu的版本号:

lsb_release -c

3.更新源

sudo apt update

猜你喜欢

转载自www.cnblogs.com/sunlingC/p/11120434.html