If you are used to RPM-based Linux-distributions such as Red Hat and SUSE, it is quite a shock getting used to package management on Ubuntu Server. The most difficult part is the layered organization of Ubuntu package management services. Nevertheless, in many ways Ubuntu offers a much easier way to manage packages based on the Debian package format. Understanding how Ubuntu Package management works allows you to do your work as a Ubuntu Server administrator much more efficiently, and even update your system in one single command. In this article we'll explain how it works.
Ubuntu uses the same package management solutions as Debian. Package management on Ubuntu Server is based on a database that keeps track of all software packages that are installed. The most fundamental of all is the dpkg-database, which is based directly on the Debian package management utility. On top of that sits the apt database which is stored in /var/lib/apt. To manage packages in this database, you can use the "apt-get" command or the "aptitude" command. Both do more or less the same. If a graphical user interface is installed, the Synaptec utility can be used as well. In this article you'll read how to work with these tools.
Managing software repositories
Apart from the database that manages packages that are installed on your server, there is also the software repository as a second fundamental component that you need for package management. These repositories are basically
Since these sources refer to Internet sites as well as local installation sources, they help you in keeping your server up to date. The "apt-get" command always uses this list of sources before installing new software. To make sure that the list is up to date, you have to use the "apt-get update" command. This makes sure that the indexes that your server keeps locally are updated so that they know about new software packages that have become available. Once the indexes are updated this way, you can use "apt-get upgrade" to upgrade packages on your server to their latest versions or "apt-get install package-name" which will install the most recent version of the package that you want to use.
Managing packages with "aptitude"
Another command that works on the same package database, is "aptitude". This is not so much a command that you would use to install or upgrade packages, but more a command that is used for package management. You would use this command, for example, to search for packages that match a given keyword, e.g.: "aptitude search xen". This displays a list of all packages that match the description xen. The command would give a result like in listing 1.
Listing 1: Searching packages with "aptitude"
sander@RNA:~$ aptitude search xen
p ubuntu-xen-desktop - Xen software for running on servers. p ubuntu-xen-server - Xen software for running on servers. p xen-doc-2.6.16 - Linux kernel specific documentation p xen-docs-3.0 - documentation for XEN, a Virtual Mac v xen-headers v xen-headers-2.6 p xen-headers-2.6.16 - Header files related to Linux kernel p xen-headers-2.6.19-4 - Common header files for Linux 2.6.19 p xen-headers-2.6.19-4-gener - Common header files for Linux 2.6.19 p xen-headers-2.6.19-4-serve - Common header files for Linux 2.6.19 v xen-hypervisor v xen-hypervisor-3.0 p xen-hypervisor-3.0-i386 - The Xen Hypervisor for i386 p xen-hypervisor-3.0-i386-pa - The Xen Hypervisor for i386 (pae ena v xen-hypervisor-i386 v xen-hypervisor-i386-pae p xen-image-2.6.19-4-generic - Linux 2.6.19 image on PPro/Celeron/P p xen-image-2.6.19-4-server - Linux xen 2.6.19 image on x86. p xen-ioemu-3.0 - XEN administrative tools p xen-restricted-modules-2.6 - Non-free Linux 2.6.17 modules on x86 v xen-source v xen-source-2.6 p xen-source-2.6.16 - Linux kernel source for version 2.6. p xen-tools - Tools to manage debian XEN virtual s v xen-utils p xen-utils-3.0 - XEN administrative tools p xen-utils-common - XEN administrative tools - common fi p xengine - A benchmark program for the X Window p xenman - A graphical Xen management tool v xenx-doc-2.6
From the list of all these packages, you can next use the command "aptitude show" to get more information about a package. For example, use "aptitude show xen-source" to get a description of the xen-source package if it is already installed, or use "apt-get install xen-source" to install it now.
If you don't like to manage packages from the command line, there is good news. The aptitude utility can work in menu mode as well, but to do that you must make sure that the right terminal setting is used. To do this, first type export TERM=vt100. Next run "aptitude" again, and you'll see the interface from Figure 1. From this interface you can check which packages are installed and which are not from an intuitive menu interface.
GUI package management
If managing packets from the console using "apt-get" or "aptitude" is not ideal for you, you might want to do it from a graphical user interface instead. One of the tools that comes with the graphical interface is the Synaptic package manager, which is based on the apt database as well. As you see in Figure 2, it offers an intuitive mouse-driven interface to help you install and manage software packages.
In Synaptic, the "Sections" button is a good starting point. This button allows you to see all available software, organized by software category. To see what's inside a category, click it, and in the right part of the Synaptic window you'll see a list of available packages. After clicking an individual package, you'll see a description of the package, allowing you to see exactly what is in the package. Next, select the "Mark for Installation" option and click "Apply." This will bring up the window that you see in Figure 3, asking you if you really want to install this package. From this window, click "Apply" to start the package's installation.
Another useful option from the Synaptic interface is the "Search" feature. It works very easily: Click "Search," and in the window that pops up, select the software that you are looking for. Click "Search" again and you'll see a list with all matching packages in it. Next, mark them for installation and click "Apply" if you really want to use these packages.
For first time users, the Ubuntu server package management utilities are quite intimidating. The most important reason for that is that a layered architecture with related commands is used to manage software on your server. The most important system is based on the apt package database. In this article you have learned how to use the commands "apt-get" and "aptitude" to perform package management from the command line. You've also seen how the Synaptic package manager can make package management easier if you are using a graphical environment.
This was first published in August 2007