Pin Me

Package Management in Debian Using dpkg And APT

written by: Pranav Thadeshwar•edited by: Lamar Stonecypher•updated: 3/27/2009

Debian is one of the most respected Linux distributions available today. Part of its popularity is due to its incredibly slick and useful package management system - dpkg and APT. In this article, we will try to learn more about them, along with a few useful commands to manipulate them.

  • slide 1 of 3


    Out of the hundreds of Linux distributions available for free today, a select few hold what you'd call "geek cred." These distributions have stood the test of time and are some of the most popular distros available today. While the reason for a distro's popularity could be just about anything, it's generally the community and bundled software which make and separate a distribution from the hundreds of others available.

    Debian's one of them. Initially released in 1993, its community has been churning out incredibly stable releases for well over a decade now. It's hard to point out one thing which has made it so popular and respected today, but its package management system is probably one of the main reasons. Known as dpkg (shortened from "debian package"), and created in 1993 as a Perl program, it has seen several revisions and changes which make it what it is today.

  • slide 2 of 3


    Since its inception, dpkg's role has changed in some ways. Before the creation of intelligent package managers, users had to find out the dependencies by hand and install them one-after-the-other. The dpkg application allows users to install package files in various ways depending on their needs and intentions.

    To install an application/package, you have to download a package file (.deb files) and install it using the command "dpkg -i <filename_of_package>"

    The .deb files are simple archive files with some metadata and the actual application/package. Dpkg unpacks these files, looks at the metadata and information and installs it in the proper locations, and finally modifies a few configuration and local files which allow it to remember that this package has been installed. This allows users to have a list of packages installed and dpkg bundles in various tools which help the user in making package-management easy.

    Here are a list of commands which allow you to use dpkg:

    dpkg -i <filename_of_package> -- To install a package.

    dpkg -l [optional pattern to list specific packages] -- To list the installed packages, optionally in a pattern.

    dpkg -r <package_name> -- To remove a package.

    Since it's quite limited in its functionality, most users will never use dpkg directly. They will use a frontend to ease the job of installing dependencies and packages, which brings me onto my next topic.

  • slide 3 of 3


    APT comes in where dpkg stops. The Advanced Packaging Tool, or APT, is a command-line front-end that works with dpkg in Debian (and its derivatives) to manage packages a lot more efficiently. Unlike dpkg where a user has to download a package and its dependencies manually, apt does all the work by itself. It will calculate the dependencies needed for any package, download them, and install everything in order so you don't have to. Since its creation in 1998 and its first release with Debian in 1999, it has been changing and adding features to make itself incredibly useful to all Debian users. A testament to that fact is the number of packaging systems it has been adapted to. Apt can work with rpm, has been ported to Mac OS X, and is also available in OpenSolaris. People are also working on porting apt to the iPhone.

    APT is not a single application, but a bunch of applications which together do the work of managing packages on Debian and its variants.

    Usage of apt:

    apt-get install <package_name> -- Installs a package and its dependencies, if any.

    apt-get remove <package_name> -- Removes the specified package.

    apt-get update -- Updates the APT package index (A list of all packages available from its repositories)

    apt-get upgrade -- Upgrades all the installed packages on the current system.

    Repositories: APT relies on directories called repositories to provide it with package files and dependencies. Typically, servers around the world managed by Debian or third-parties are used as repositories. The Debian project maintains a repository of over 25,000 packages which can be downloaded and installed through APT. Other sources of repositories include USB disks, CDROMS and hard-disks.

    Frontends: Since APT is a command-line application, it has many front-ends which can be used to simplify the job even more. Two of the most popular frontends available today are Synaptic (graphical) and aptitude (command-line).