Package management

Quickstart: For those too impatient to read this entire document, I find that I am able to do most of my Debian package management using apt-get. Read the manpage.

How do you install software under Debian GNU/Linux? Well, there are a lot of different ways. Whenever something is open source, you can download the source (usually as a tar.gz or tar.bz2 file that needs to be uncompressed) and compile it yourself. Or you can often just install a binary specific to your distribution and platform. Such binaries are distributed in packages.

One incredibly useful thing about Debian packages (.debs) is that the files contain both the binaries and information about the package's dependencies and conflicts. Debian packages contain control files, conffiles, and scripts to be run before and after installation and removal. One significant difference between the Debian package system and Red Hat's package management is that there is a global database with information about dependencies of .debs. In other words, you do not need to download each .deb separately and attempt to install it in order to find out what other files it will require.

But even with pre-compiled and packaged binaries, there's more than one way to do it. Here I will briefly describe some different package management tools for Debian GNU/Linux.

dpkg --- In one case dpkg is the most basic of the main Debian package management tools and is often used just as a backend. However, it can be used to install ("dpkg --install") and remove ("dpkg --remove" or "dpkg --purge" if you want to remove configuration files as well) packages. I often use "dpkg -l somepattern" to list the installation states of all packages matching "somepattern". (* is the wildcard character to match anything.) "dpkg -L somepattern" will list all of the files installed by a particular package.

dselect --- dselect is a character-based frontend to dpkg. It can be a bit overwhelming to use sometimes, but is often useful if you intend to select a large number of packages and install them. dselect provides brief descriptions of packages and allows you to search for packages. In addition to installing packages, dselect lets you choose your access method, update the list of available packages, configure, and remove packages.

apt-get --- apt-get is a newer utility than either dpkg or dselect. apt stands for advanced package tool. apt-get is invoked from the command line and can be run with many different options including "update" to update the list of available packages, "install" and "remove" to install and remove specific packages, "source" to install debian souce packages, "upgrade" to upgrade all installed packages to the newest version, and "dist-upgrade" to upgrade to a new distribution. The list of sources that apt-get queries is specified in the file "/etc/apt/sources.list". There are several other apt tools. For example, "apt-cache search somepattern" and "apt-cache show somepackage" can be used to get descriptions of packages.

console-apt --- console-apt (or capt for short) is a sort of replacement for dselect. The ncurses interface is cleaner, and capt allows for more sophisticate sorting and filtering. It was designed to fall somewhere in between dselect and apt-get. aptitude, gnome-apt, and platypus are other graphical frontends.

alien --- Red Hat's package format, the rpm is widely available. It's possible that the program you want to install is available as a .rpm but not as a .deb. Fortunately, you can install PRMs in Debian with the use of the alien utility. First you need to download the RPM. Then you can install it with "alien -i rpmname" where "rpmname" is the name of the RPM you wish to install. alien can also be used to convert from Debian to Red Hat packages as well as to and from tgzs and slps (Stampede's format). Conectiva has put together a similar utility to put this compatibility functionality into RPM based systems.

make --- Finally, you can bypass Debian's package management and choose to compile directly from source. The source you download will likely be a tgz, tar.gz or tar.bz2 file which will need to be uncompressed with "tar", "gunzip", or "bunzip2". (For example, somesrc.tgz could be extracted with the command "tar xzvf somesrc.tgz.) After untarring, change to the source directory and look for a README file. Usually you have to run a configure script and then run "make" and "make install".

I'm a big fan of Debian's package management. For some articles about alternatives, comparing package managers, and more information about installing packages, see the linksprovided.