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
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
sedto replace mirrors in
The other answers, including the accepted answer, are no longer valid (for Ubuntu 11.04 and newer) because they recommended Debian packages such as
apt-spywhich do not work with Ubuntu.
sed to replace mirrors in
sudo sed -i -e 's#us.archive.ubuntu.com/mirror.math.ucdavis.edu#g' /etc/apt/sources.list