How do you select the fastest mirror from the command line?
- by Evan
I want to update my sources.list file with the fastest server from the command line in a fresh Ubuntu Server install. I know this is trivially easy with the GUI, but there doesn't seem to be a simple way to do it from from the command line?
There are two different working answers to this question below:
Use apt-get's mirror: method
This method asks the Ubuntu server for a list of mirrors near you based on your IP, and selects one of them. The easiest alternative, with the minor downside that sometimes the closest mirror may not be the fastest.
Command-line foo using netselect
Shows you how to use the netselect tool to find the fastest recently updated servers from you -- network-wise, not geographically. Use sed to replace mirrors in sources.list.
The other answers, including the accepted answer, are no longer valid (for Ubuntu 11.04 and newer) because they recommended Debian packages such as netselect-apt and apt-spy which do not work with Ubuntu.
Use sed to replace mirrors in sources.list
sudo sed -i -e 's#us.archive.ubuntu.com/mirror.math.ucdavis.edu#g' /etc/apt/sources.list