Skip to content

Make apt Faster Using Mirrors

You can make apt faster for Ubuntu by adding mirrors to apt's sources.

Add the following lines to the top of the file /etc/apt/sources.list:

deb mirror://mirrors.ubuntu.com/mirrors.txt CODENAME main restricted universe multiverse
deb mirror://mirrors.ubuntu.com/mirrors.txt CODENAME-updates main restricted universe multiverse
deb mirror://mirrors.ubuntu.com/mirrors.txt CODENAME-backports main restricted universe multiverse
deb mirror://mirrors.ubuntu.com/mirrors.txt CODENAME-security main restricted universe multiverse

Note

Replace CODENAME with the appropriate codename of your Ubuntu installation.

You can execute the following command to get the CODENAME of your instance:

cat /etc/*release* | grep CODENAME | head -n 1 | cut -d '=' -f2

Sample for Ubuntu 18.04

deb mirror://mirrors.ubuntu.com/mirrors.txt bionic main restricted universe multiverse
deb mirror://mirrors.ubuntu.com/mirrors.txt bionic-updates main restricted universe multiverse
deb mirror://mirrors.ubuntu.com/mirrors.txt bionic-backports main restricted universe multiverse
deb mirror://mirrors.ubuntu.com/mirrors.txt bionic-security main restricted universe multiverse

References