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
Since some sources use addition folders as part of their path it might be better to use the alternate separator syntax.
sudo sed -i 's%us.archive.ubuntu.com%mirrors.gigenet.com/ubuntuarchive/%' /etc/apt/sources.list