Tuesday, November 26, 2013

Automatically Select Fastest Servers for apt in Ubuntu

Using GUI-based Ubuntu, it is very easy to select the fastest (or change, in general) mirror servers for apt purposes. All you need to do is just select  System|Administration|Software Sources.

But things get ugly if you want to do it on command-line. You have to update sources.lists manually. That is a tiresome job, and not cool either :D

Well, other people have thought about the same problem and they have been working solutions for this. There is a package named after netselect-apt. It allows you to update the fastest apt server automatically, via command-line.

But, there is another way, and it is easier. All you have to do is adding these lines at the top of your sources.list (assuming you are using Ubuntu 12.04):

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


That is it. You need to perform 'apt-get update' first, and then 'apt-get upgrade'. Notice that the server used is the fastest one (relative to your location).

2 comments: