Ubuntu 18.04 更换国内源


1. 备份源列表

sudo cp /etc/apt/sources.list /etc/apt/sources.list_backup

2、修改资源镜像文件

sudo vi /etc/apt/sources.list

编辑 /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

注意:是替换,不是添加,否则执行 sudo apt-get update 命令时还是会去更新文件里存在的其他源。

3、添加阿里云域名服务器

修改 /etc/resolv.conf 文件:

sudo vi /etc/resolv.conf

添加阿里云的域名服务器:

nameserver 223.5.5.5
nameserver 223.6.6.6

4、刷新列表

更新源的索引:

sudo apt-get update

前一篇:
后一篇:

发表评论