If you want to update and upgrade your sources.list file with the fastest servers from the command line in a fresh Ubuntu Server install, it’s quite easy with the GUI, but it doesn’t seem to be a simple way to do it from from the command line. You can us deb mirror to have the best mirror picked for you automatically.
apt-get now supports a ‘mirror’ method that will automatically select a fastest mirror based on your location.
Edit sources.list file
# nano /etc/apt/sources.list
Put these codes on the top of the file, it will automatically pick a fastest mirror for you based on your geographical location.
Replace precise with the appropriate name Lucid (10.04), Maverick (10.10), Natty (11.04), Oneiric (11.10), Precise (12.04), Quantal (12.10), and Raring (13.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
Or you can use netselect-apt program, to install it
# apt-get install netselect-apt
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following extra packages will be installed:
curl libcurl3 librtmp0 libssh2-1 netselect
The following NEW packages will be installed:
curl libcurl3 librtmp0 libssh2-1 netselect netselect-apt
0 upgraded, 6 newly installed, 0 to remove and 0 not upgraded.
Need to get 852 kB of archives.
After this operation, 1542 kB of additional disk space will be used.
Do you want to continue [Y/n]? y
To run netselect-apt
In my case, one of my vps is located at Arizona
The fastest 10 servers seem to be:
Wait for netselet-apt to run, when its finished you will have a new sources.list in the directory where you executed the command in. You can either move or copy it to your /etc/apt/ directory by executing:
# mv ./sources.list /etc/apt/sources.list
# cp ./sources.list /etc/apt/sources.list
After having a new sources.list file you will need to run update command
# apt-get update
stable|testing|unstable|experimental|woody|sarge|etch|sid Specify which distribution of Debian to use. By default stable is used.
While generating OUTFILE include also deb-src lines to use with ‘‘apt-get source’’ to obtain Debian source packages.
-i, –infile INFILE
Use INFILE instead of mirrors_full for reading mirror list. The file must be in the same format as mirrors_full.
-o, –outfile OUTFILE
Use OUTFILE instead of sources.list.
Include also non-free section while generating OUTFILE.
Use FTP mirrors instead of HTTP and generate OUTFILE accordingly.