Learn Linux 14: Package Management




If we spend any time in the Linux community, we hear many opinions as to which of the many Linux distributions is “best.” Often, these discussions get really silly, focusing on such things as the prettiness of the desktop background (some people won’t use Ubuntu because of its default color scheme!) and other trivial matters.

The most important determinant of distribution quality is the packaging system and the vitality of the distribution’s support community. As we spend more time with Linux, we will see that its software landscape is extremely dynamic. Things are constantly changing. Most of the top-tier Linux distributions release new versions every six months and many individual program updates every day. To keep up with this blizzard of software, we need good tools for package management.

Package management is a method of installing and maintaining software on the system. Today, most people can satisfy all of their software needs by installing packages from their Linux distributor. This contrasts

with the early days of Linux, when one had to download and compile source code to install software. There isn’t anything wrong with compiling source code; in fact, having access to source code is the great wonder of Linux. It gives us (and everybody else) the ability to examine and improve the system. It’s just that having a precompiled package is faster and easier to deal with.

Packaging Systems

Different distributions use different packaging systems, and as a general rule, a package intended for one distribution is not compatible with another distribution. Most distributions fall into one of two camps of packaging technologies: the Debian .deb camp and the Red Hat .rpm camp. There are some important exceptions such as Gentoo, Slackware, and Arch, but most others use one of these two basic systems,

Packaging systemDistributions (partial listing)
Debian-style (.deb)Debian, Ubuntu, Linux Mint, Raspbian
Red Hat–style (.rpm)Red Hat Enterprise Linux, CentOS, Fedora, OpenSUSE

How A Package System Works

The method of software distribution found in the proprietary software industry usually entails buying a piece of installation media such as an “install disk” or visiting each vendor’s website and downloading the product and then running an “installation wizard” to install a new application on the system.

Linux doesn’t work that way. Virtually all software for a Linux system will be found on the Internet. Most of it will be provided by the distribution vendor in the form of package files, and the rest will be available in source code form that can be installed manually.

Package Files

The basic unit of software in a packaging system is the package file. A package file is a compressed collection of files that comprise the software package. A package may consist of numerous programs and data files that support the programs. In addition to the files to be installed, the package file also includes metadata about the package, such as a text description of the package and its contents. Additionally, many packages contain preand post-installation scripts that perform configuration tasks before and after the package installation.

Package files are created by a person known as a package maintainer, often (but not always) an employee of the distribution vendor. The package maintainer gets the software in source code form from the upstream provider (the author of the program), compiles it, and creates the package metadata and any necessary installation scripts. Often, the package maintainer will apply modifications to the original source code to improve the program’s integration with the other parts of the Linux distribution.


While some software projects choose to perform their own packaging and distribution, most packages today are created by the distribution vendors and interested third parties. Packages are made available to the users of a distribution in central repositories that may contain many thousands of packages, each specially built and maintained for the distribution.

A distribution may maintain several different repositories for different stages of the software development life cycle. For example, there will usually be a “testing” repository that contains packages that have just been built and are intended for use by brave souls who are looking for bugs before the packages are released for general distribution. A distribution will often have a “development” repository where work-in-progress packages destined for inclusion in the distribution’s next major release are kept.

A distribution may also have related third-party repositories. These are often needed to supply software that, for legal reasons such as patents or DRM anti-circumvention issues, cannot be included with the distribution. Perhaps the best known case is that of encrypted DVD support, which is not legal in the United States. The third-party repositories operate in countries where software patents and anti-circumvention laws do not apply. These repositories are usually wholly independent of the distribution they support, and to use them, one must know about them and manually include them in the configuration files for the package management system.


Programs are seldom “stand alone”; rather, they rely on the presence of other software components to get their work done. Common activities, such as input/output, for example, are handled by routines shared by many programs. These routines are stored in shared libraries, which provide essential services to more than one program. If a package requires a shared resource such as a shared library, it is said to have a dependency. Modern package management systems all provide some method of dependency resolution to ensure that when a package is installed, all of its dependencies are installed, too.

High And Low Level Package Tools

Package management systems usually consist of two types of tools. Low-level tools that handle tasks such as installing and removing package files. High-level tools that perform metadata searching and dependency resolution.

DistributionsLow LevelHigh Level
Debian styledpkgapt-get, apt, aptitude
Red Hat Enterprise stylerpmyum, dnf

Common Package Management Tasks

Many operations can be performed with the command line package management tools. We will look at the most common.

Finding A Package In A Repository

Debianapt search search_string
Red Hatdnf search search_string

Installing A Package From A Repository

Debianapt install package_name
Red Hatdnf install package_name

Removing A Package

Debianapt purge package_name
Red Hatdnf erase package_name

Removing Orphan Packages

Debianapt autoremove
Red Hatdnf autoremove

Updating Packages From A Repository

Debianapt update; apt upgrade
Red Hatdnf update

Listing Installed Packages

Debianapt list --installed
Red Hatdnf list --installed

Displaying Information About An Installed Package

Debianapt show package_name
Red Hatdnf info package_name

Installing A Package from A Package File

Debiandpkg -i package_file
Red Hatrpm -i package_file

Upgrading A Package from A Package File

Debiandpkg -i package_file
Red Hatrpm -U package_file

Determining Whether A Package Is Installed

Debiandpkg -s package_name
Red Hatrpm -q package_name

Finding Which Package Installed A File

Debiandpkg -S file_name
Red Hatrpm -qf file_name


In this chapter, we will looked at some of the command line tools used for package management. While all the major distributions provide powerful and sophisticated graphical programs for maintaining the system, it is important to learn about the command line programs, too.