Kubuntu Breezy - Absolute beginners

Samstag, Januar 07, 2006

Basic Knowledge II: Repositories and apt

....or what the hell is the sources.list

If you're new to (K)ubuntu (or any debian based Linux distributions) you may ask yourself what those things like "Repository" and "sources.list" are.
If you followed a bit this blog I'm sure you've already come across it :-)

Every (k)ubuntu has its sources list already from the first installation. It's always in this directory:
/etc/apt/sources.list

So it's in the "apt" folder. Apt is a program that helps you installing/removing programs and keeping them up-to-date. (Usually you need internet access doing this - at least for the updates it's indispensible).

Instead of using apt with the konsole (as described below), you can also use its graphical frontend: Synaptic in Ubuntu, Adept in Kubuntu.

The sources.list tells apt from where it can download the programs - from the install cd / dvd, or from different http sites on the internet. At the beginning your sources.list may look more or less like that.
You'll see a lot of lines with # or ## before them.
The sign # means that the line is "commented". If somebody tells you to "uncomment" a line it means: remove the # sign. If you do this, the line is activated (if it's commented, it's inactive).
If a line begins with ## this line is usually a description or help for the user - NOT for the program. Do never uncomment those lines!

You'll also notice that some lines begin (or begin right after the # sign) with "deb" or "deb-src". Those lines shows the origin for the sources and for the packages. They're called Repositories.
If I uncomment the first line of my sources.list
(#deb cdrom:[Ubuntu 5.10 _Breezy Badger_ - Release i386 (20051012)]/ breezy main restricted)
apt will search in my CD ROM for packages to install / uninstall. Of course I need to put in the Install CD, otherwise it'll give me an error.
But since I have internet access I don't use the CD, that's why I commented it.

The final question is of course: which line do you have to comment and which one do you have to uncomment? First of all: whatever you do, do it for both lines: deb and deb-src.
I'd advise to uncomment the repository which ends with "universe multiverse".
Universe multiverse contains software which is unsupported by Ubuntu itself and which may be not under a free licence (like video codecs) but which is very useful. If you use my blog you should always have that repo active.

If you look at my file, I'have uncommented every repos except the CD and the backports. You can comment the backports if you don't need the newest version of programs. If you always want to have the newest version of firefox and other programs, you should uncomment it. You can read in my sources.list that the backports repo would contain software which maybe not extensivly tested - but at ubuntuforums (read here) they tell that it's completely safe to use backports.

Now you know WHAT to do, but maybe you don't know HOW.
Open your konsole and type
sudo kwrite /etc/apt/sources.list
(If you're using GNOME its: sudo gedit /etc/apt/sources.list). Now you can comment and uncomment the lines - and even add more repos, if you want to.
To have some ideas about the different repos, take at look at those links: Recommended sources.list from ubuntu_demon (with links) and The sources.list generator

Now after you've set up your sources.list you can use it :-)

With the Konsole:
sudo apt-get update
tells apt to get the updated sources.list
sudo apt-get upgrade
makes an upgrade of your whole system
sudo apt-get install Program
Installs a program (of course you have to substitute Program with the name of the program you want to install, e.g. kompose :-)
For more information you can just type
man apt-get


You can get more useful information about apt here.

If you search around a bit for apt, don't be scared if you read a lot about Debian. Since (K)ubuntu is Debian based, both distributions have a lot in common - so both use apt.