把Ubuntu18的apt源更改为阿里云镜像

时间:2022-06-01 12:37:25

在正式更改前,建议先备份原文件

sudo mv /etc/apt/sources.list /etc/apt/sources.list.bak

进入apt源配置目录,添加aliyun.list

cd /etc/apt/sources.list.d/
sudo vim aliyun.list

在aliyun.list添加以下内容:

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

最后更新软件包

sudo apt-get update
sudo apt upgrade

对apt源的更改,需要有root权限。