How to select the fastest apt mirror on Ubuntu Linux - LinuxConfig.org


#1
The following guide will provide you with some information on how to improve Ubuntu's repository download speed by selecting the closest, that is, possibly fastest mirror relative to your geographical location.
This is a companion discussion topic for the original entry at https://linuxconfig.org/how-to-select-the-fastest-apt-mirror-on-ubuntu-linux

#2

pcolby

Excellent article - very helpful! Thanks :slight_smile:

Once small tip: sed’s substitute command (s) allows you to swap the ‘/’ separator with any other single character. Since URLs often contain ‘/’ chars, its convenient to use a different separator, such as ‘|’. So, you example:

sed -i 's/http:\/\/us.archive.ubuntu.com\/ubuntu\//http:\/\/ubuntu.uberglobalmirror.com\/archive\//' ...

becomes

sed -i 's|http://us.archive.ubuntu.com/ubuntu/|http://ubuntu.uberglobalmirror.com/archive/|' ...

which is just a bit easier, since you don’t have to manually escape the cut-and-pasted URLs :slight_smile:

Also, the in-place argument (-i) accepts a filename suffix to automatically create a backup. So, for example,

sudo sed -i.backup 's...' /etc/apt/sources.list

will automatically creates a file /etc/apt/sources.list.backup, which is a copy of the file prior to sed’s modifications (though I’d probably back it up manually with cp -a beforehand anyway).

Thanks again!


#3

Justin Johnston

Nice article, although it seems netselect doesn’t run on Ubuntu 18.04 yet.

As a work-around, I wrote this one-liner that shows the top 20 fastest mirrors based on ICMP latency using ping.

for mirror in $(wget -qO - mirrors.ubuntu.com/mirrors.txt|sed ‘s/^http:////;s//.$//’) ; do echo $(ping -c 1 $mirror|grep "^64 bytes.time="|sed 's/^64 bytes.=//;s/ .$//’) $mirror ; done|sort -n|grep “^[0-9]”|head -n 20


#4

Sajeev Ramasamy

when i run the netselect command, i’m getting the following error: netselect: socket: Permission denied. Could anyone help me?


#5

Lubos Rendek -> Sajeev Ramasamy

use sudo command as shown on the above example


#6

Sajeev Ramasamy -> Lubos Rendek

That’s what baffles me. I’m getting the error even when I use sudo


#7

Lubos Rendek -> Sajeev Ramasamy

Also have a look here: How to create sudo user on Ubuntu 18.04 Bionic Beaver Linux - LinuxConfig.org


#8

Lubos Rendek -> Sajeev Ramasamy

Is you user in sudo group? Run:

$ id whoami


#9

Sajeev Ramasamy -> Lubos Rendek

the user belongs to the sudo group, also i’m trying this in WSL.


#10

Sajeev Ramasamy -> Lubos Rendek

My user belongs to the sudo group, I should also mention that I’m trying this in WSL.


#11

David Orozco

love this approach