Speeding Up Ubuntu Updates by Switching to the Aliyun Mirror

Published:

Ubuntu’s default software repositories can be painfully slow, especially when downloading packages or refreshing the package index. To improve download speeds, I switched the system to Aliyun’s Ubuntu mirror.

Before changing anything, make a backup of the existing APT configuration:

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

This makes it possible to restore the original configuration if something goes wrong.

Next, open the sources list with:

sudo vi /etc/apt/sources.list

Remove the existing contents and replace them with the following configuration:

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-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports 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

The same process applies when switching to other mirrors, but make sure the repository path matches the Ubuntu installation. Ubuntu systems may use either ubuntu or ubuntu-ports, and choosing the wrong one can cause APT to stop working correctly. I ran into this problem myself after selecting the wrong repository.

Save the file, then refresh the package lists and upgrade the installed packages:

sudo apt-get update
sudo apt-get upgrade

APT update and upgrade commands

Updated Ubuntu package lists

After changing to the Aliyun mirror, Ubuntu was no longer stuck with the extremely slow default repository speeds.