The GNU/Linux Debian sources.list is a file that does various functions:
- it lists the address from where packages (programmes) are downloaded and installed from;
- it lists the components (main, contrib or non-free) that you want to use; and
- it lists which distribution (stable, testing or unstable) you want to download; currently there are three different distributions to choose from: stable; testing; and unstable.
The sources.list file is stored in /etc/apt/sources.list and can be edited as root with the following (if nano is not available on the system you can fall back to “vi” or any other editor):
# nano /etc/apt/sources.list
This is an example of a default sources.list file:
deb http://http.debian.net/debian wheezy main deb-src http://http.debian.net/debian wheezy main
deb http://http.debian.net/debian wheezy-updates main deb-src http://http.debian.net/debian wheezy-updates main
deb http://security.debian.org/ wheezy/updates main deb-src http://security.debian.org/ wheezy/updates main
From this example file you can easily determine that:
- it downloads packages from http://http.debian.net/debian;
- it uses the “main” components only, and does not include any non-free components; and
- it uses the stable (Wheezy) distribution.
Adding Non-Free Repositories and Moving to the Testing Distribution
There may be some occasions when it might be necessary to install software from a non-free repository, for example if your hardware needs a proprietary firmware blob to operate properly.
To add the contrib and non-free repositories simply edit the sources.list and add the words “contrib non-free” after the word “main” everywhere it appears inthe file.
To change the distribution from stable (wheezy) to testing (jessie) simply edit the sources.list and replace the words wheezy with the word testing everywhere it appears in the file.
# nano /etc/apt/sources.list
Edit the files to look similar to this (note: I have not reproduced the whole file again), save the file and exit:
deb http://http.debian.net/debian testing main contrib non-free deb-src http://http.debian.net/debian testing main contrib non-free
Changing the Download Mirror
The official list of Debian mirror sites is at http://www.debian.org/mirror/list
One problem is that South Africa does not have a primary mirror site, just secondary mirrors, which raises the question: Is it better to download from a local secondary mirror, or a foreign primary mirror?
To help select the best mirror available from your location you can use the programme “netselect-apt” which can determine and suggest the site with the least latency. Running netselect-apt overwrites your existing sources.list, so making a backup first is advised.
# apt-get install netselect-apt # netselect-apt
Once the best mirror has been determined you can edit your original sources.list file and change the mirrors to the suggested mirror. The security update mirrors should not, however, be changed.
Update the System with the Latest Packages
Once the sources.list file is updated is is then necessary to update your system with the latest packages from you newly selected distribution and repository.
This is done as root with the following:
# apt-get update # apt-get upgrade
“Update” is used to resynchronize the package index files from their sources and “upgrade” is used to install the newest versions of all packages currently installed on the system.
If you are moving from on distribution to another (moving from stable to testing), or if after running apt-get upgrade there is a message saying that certain packages were held back, you may want to do a dist-upgrade instead:
# apt-get update # apt-get dist-upgrade
This work by Clinton Pavlovic is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.