If you do not have access to a graphical tool such as Synaptic, you can hand-edit the servers that you want APT to read from using a console-based editor. This also is helpful if you want to add a custom repository, if you want to use a particular version of Ubuntu (such as a newer version than you first installed), or if you want to use a local repository to save downloading packages repeatedly.
APT's sources are stored in the /etc/apt/sources.list file, so you'll need to launch your editor through sudo to make changes. Reading the sources.list file can be baffling at first, but it is actually quite easyparticularly as people running custom repositories will often tell you exactly what to type in.
The two types of line you will find in sources.list are "deb" and "deb-src". The first is downloaded program packages that can be installed and run as normal, but the second offers pre-packaged source code. Admittedly, the deb-srcs are very rarely used, but there is no harm having them around. Commentslines starting with #are ignored by APT. So, if you want to temporarily disable a repository, just insert a # at the start of its line, save the file, and re-run apt-get update.
Each line is made up of the following parts:
[deb/deb-src] url distribution [components...]
The URL will look something like "http://gb.archive.ubuntu.com/ubuntu/", and points to the location where the APT index and packages are stored. This URL is the same for all versions of Ubuntu; what changes is the "distribution" part of the line, which comes next. This is set to the first part of the Ubuntu code-name for the distro you are using"warty" for 4.10, "Warty Warthog"; "hoary" for 5.04, "Hoary Hedgehog"; "breezy" for 5.10, "Breezy Badger"; and "dapper" for 6.06, "Dapper Drake". Incidentally, the next code-name for Ubuntu is "Edgy Eft", so if you want to upgrade to that you need to use the distribution name "edgy".
After the distribution comes the individual components you want to select. By default this is usually "main restricted," which means you want to download the main Ubuntu packages, as well as any restricted copyright material. Packages under restricted copyright things are things like binary drivers, so it is best to leave "restricted" enabled. You mayprobably on a different deb linehave the same URL and distribution, this time with the "universe multiverse" components. We highly recommend you have these two components enabled, as they open up a huge collection of software that will enable you to get the most out of this book and Ubuntu itself.
At the bottom of the sources.list file there are usually some deb lines that handle security updates. This has a special URL, security.ubuntu.com, and a special distribution name, dapper-security. This should be left enabled at all times.
If you have made changes to your sources.list file, you must run apt-get update to download the new package information before running any further APT commands.
Before changing your sources.list file, we highly recommend keeping a backup of the original by running this command:
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
Was this article helpful?