Skip to content

Debian Package Management on Linux

Use tools to install, update, uninstall packages, obtain information such as version, content, dependencies, integrity, and installation status.

Debian package management on Linux is an excellent way to distribute, install, and uninstall software for the Debian and Ubuntu distros.

A package in a nutshell is a file that contains the necessary information so that the package manager can
install, maintain, and remove programs as well as other files required for a particular application.

An important feature of Linux is the modularization of its components and the intensive use of shared libraries. This also applies to application bundles.

It is quite common for a programmer to use shared libraries and not include them in his application.

It is common when we try to install a given package must first install another package that
contain the prerequisites or libraries for your installation. Each package load the required dependency information.

Large software projects use distributing the various modules of your application in various packages that may or may not be installed according to your use.

The organization of an application into several packages allows the administrator to install only those that are really necessary, avoiding having to install components that will not be used. Following the line of package managers, two major Linux distributions stood out.

Debian combined the GNU tools, the Linux Kernel, and other important free software to form the distribution called Debian GNU/Linux. This distribution is made up of a large number of software packages.

Each package in the distribution contains executable programs, scripts, documentation, and configuration information. The Debian package manager is versatile and robust. Ubuntu and SteamOS follow the Debian standard.

The American company Red Hat was also one of the pioneers in the serious treatment of Linux. From the beginning, it has been one of the leading global distributions with great influence.

The creator of RPM, the package manager most used today on Linux, Red Hat has a distribution focused on the server market. Fedora, Mandriva, SuSE, openSUSE, CentOS, and Oracle Linux follow the RPM standard.

Debian is attentive to details that allow us to produce high quality and stable programs.

Facilities can be easily configured to serve multiples purposes, such as low-packet Linux firewalls, scientific desktop stations, and high-class network servers performance.

This distribution is especially popular among advanced users because of its technical excellence and attention to the needs and expectations of the Linux community.

Debian also introduced many features to the system that are now routine, such as the package management system for easy installation and removal of software and also the possibility of allowing the system to be updated without requiring reinstallation.

The package manager tools allow the administrator of a Debian system to have complete control over the installed software, including the ability to install a simple package or automatically update the entire operating system.

Packages can also be protected from being updated.

The names of the Debian packages accompany the following
standard:

![](https://www.certificacaolinux.com.br/wp-content/uploads/2019/03/IMAGEM07.png)
- Package Name: The package name is a brief description of its content. If more than one word is used, it is separated by - a dash; Software version: Each package has its own version number, which may vary between major version and fixes applied; - Package version: Packages may also have different distribution versions. The version of the package may also indicate what platform it was prepared for; - .deb extension: For easy identification of Debian packages.

Examples:

abiword-gtk_1.0.2+cvs.2002.06.05-1_i386.deb

abiword-plugins_1.0.2+cvs.2002.06.05-1_i386.deb

Tools for manipulating packages

Dpkg

The dpkg command is the utility responsible for managing packages on Debian systems.

It maintains the information of the installed packages basically in the /var/lib/dpkg/available and /var/lib/dpkg/status files. These files contain the list of available packages and status, respectively.

The most common options are:

  • -E: This option does not rewrite an already installed package of the same version;
  • -G: This option does not rewrite an already installed package, even if it is older;
  • -R: Processes all packages found in a given directory recursively.

The most frequent actions are:

  • -i package-name: Installs the package package-name. This process involves backing up old files that already exist on the system, unpacking, installing, and configuring. This action can also be referenced with —install package-name;
  • -l search key: List package information containing the same search key in the name; -L packagename
  • : Lists the files installed by the package-name package package package;
  • — print-avail package-name: ‘List all information available about the package package-name in /var/lib/dpkg/evaluable;
  • — purge package-name: Removes the entire package package-name;
  • -r package-name: Removes all package files, except settings;
  • -s package-name: Shows package status;
  • -S file: Search for a file in installed packages;
  • —unpack packagename: Unpacks a package but doesn’t install;
  • —configure packagename: Configures an uninstalled package.

Examples:

Install a package using dpkg

# dpkg -i acct_6.3.5-32_i386.deb

Remove a package using dpkg

# dpkg —purge ace-of-penguins_1.2-3_i386.deb

The dpkg can also be used to find out which package a particular file belongs to:

# dpkg -S stdio.h

libc6-dev: /usr/include/stdio.h

libc6-dev: /usr/include/bits/stdio.h

perl: /usr/lib/perl/5.6.0/core/nostdio.h

Another possibility is discover the packages installed on the system from a key:

# dpkg -l | grep Mozilla

ii mozilla-browse 0.9.6-7 Mozilla Web Browser

The /etc/dpkg/dpkg.cfg file contains the default options when dpkg is executed.

The dpkg control files reside in /var/lib/dpk directory. Two interesting files in this directory are:

/var/lib/dpkg/available: List of available packages;

/var/lib/dpkg/status: Status of the installed packages. It tells you when they were installed, removed, etc.

dpkg-reconfigure utility

Use:

# dpkg-reconfigure [package name]

The dpkg-reconfigure command reconfigures a package already installed on the system. It has the same effect as re-installing the package.

Example:

# dpkg-reconfigure debconf

Apt-get utility - the true Swiss Army knife

The apt-get (Advanced Package Tool) command is an advanced package manager.

It can use local or remote files to install or update packages.

This way it is possible to update the entire Debian system via ftp or http. This manager also maintains information about packages and their dependencies.

Due to its ease of operation, apt-get is the preferred method for manipulating packages. This utility offers dozens of options configured in the /etc/apt/apt.conf file.

The /etc/apt/sources.list file contains the locations where will apt-get find the packages, the verified distribution (stable, testing, unstable, Woody, Sarge) and the section that will be copied (main, non-free,
contrib, non-US).

Below is a simple file example
/etc/apt/sources.list with an explanation of the sections:

deb http://www.debian.org/debian stable main contrib non-free

deb http://nonus.debian.org/debian-non-US stable non-US

In the /etc/apt/apt.conf file we can specify options that will modify the behavior of the apt-get program during manipulating the packages.

apt-get uses a list of packages to check whether existing packages on the system need to be updated or not. The newest list of packages is copied using the apt-get update command.

The apt-get is very useful because the administrator does not need to manually copy the package he wants from the Internet install, let alone deal with dependencies, as long as what it needs be in the repositories indicated on sources.list.

The most common options for this utility are:

  • -d: Download the files but don’t install. It is useful for downloading large volumes of packages for subsequent installation;
  • -s: Simulates the installation of the packages but does not make modifications;
  • -y: Answers in the affirmative for all questions asked during the installation/uninstallation process of the packages.

The most common commands are:

  • dist-update: This command automatically updates the Debian system;
  • install: This command installs a specific package specified by name;
  • remove: This command removes a particular package specified by name;
  • update : This command makes a list of all available packages. The process is done automatically before any modifications to the packages;
  • upgrade: This command is used to safely update the system, since it does not install packages that may cause any conflict or failure in the configuration files.

Examples:

# apt-get install airsnort

Install the airsnort.x.y.deb package. This command accepts installing more than one package by separating names by spaces. It’s just needed to specify the package name, without version (X), revision (Y) and suffix (.deb).

If necessary, apt-get will install automatically the dependencies necessary for the proper functioning of a
package.

Apt-get can update your entire distribution in an intelligent and safe way. It reads the list of packages available on remote server, checks which are installed and their versions and updates the old packages.

# apt-get upgrade

The files can be copied via FTP, http, local copy of the files to the hard disk or CD-ROM.

Do you want “graphic” mode? Use aptitude to install and remove software

The aptitude utility is an interface for facilitate the use of APT. It shows a list of packages and allows the user to select packages to be installed or uninstalled interactively.

It also acts as a powerful system for searching for packages and package details.

Originally developed for Debian, it is also present in other distributions, as well as in some that use the RPM standard.

It uses the library ncurses for terminal emulation and interactive menus, emulating the use of
apt-get in a simpler and more intuitive way.

Calm down! There’s even more! See the apt-cache command

The apt-cache utility is for manipulating and obtaining information about the packages in the apt cache.

It should be used in conjunction with some commands, to follow:

# apt-cache add: Add a package to the apt cache;

# apt-cache gencaches: Generate the apt cache;

# apt-cache showpkg: Shows some information about a particular package;

# apt-cache stats: Shows some statistics;

# apt-cache check: Checks the cache sanity;

# apt-cache search: Search the package list for a given occurrence;

# apt-cache show: Shows details about a particular package;

# apt-cache depends: Shows the software dependencies of a particular package;

# apt-cache pkgnames: List the name of all packages.

The apt-cache can be used to discover packages containing Atari emulators:

# apt-cache search atari

atari800 - Atari emulator for SVGalib/x/Curses

Stella - Atari 2600 Emulator for X windows

xmess-x - X binaries for Multi-Emulator Super System

It can also be used to learn more about a certain package, such as the Stella emulator:

# apt-cache show stella

Package: stella

Priority: extra

Section: non-free/otherosfs

Installed-Size: 830

Maintainer: Tom Lear

Architecture: i386

Version: 1.1-2

Depends: libc6 (>= 2.1), libstdc++2. 10, xlib6g (>= 3.3.5-1)

Filename: dists/potato/non-free/binary-i386/otherosfs/stella_1.1-2.deb

Size: 483430

Or if you simply want to know which are the dependencies of a package:

# apt-cache depends penguin-command

penguin-command

Depends: libc6

Depends: libpng2

Depends: libsdl-mixer1.1

Depends: libsdl1.1

Depends: zlib1g