Debian Package Management, Part 1: A User's Guide

A HOWTO for Debian package management.
APT

APT stands for “Advanced Package Tool”. It does a wonderful job of simplifying the life of a Debian user. If the last session discouraged you, fear not! APT is what I use for most of my package management. Why then, you ask, did I force dpkg on you? Because it's important to know what is underneath APT.

The APT system consists of three major parts: the configuration file, sources.list, and two programs called apt-get and apt-cache. There also are some minor parts, like apt-cdrom.

sources.list

Once you learn how to use it, /etc/apt/sources.list will become one of the most important files in your system. For the most part, sources.list consists of ftp and http addresses where APT can go to pull information, and is a great way to organize your resources in one location. A typical entry looks something like:

deb http://http.us.debian.org/debian unstablemain contrib non-free

The first part of the entry is either “deb”, for a line that specifies where to acquire binaries from, or “deb-src” which specifies where to acquire debian source packages. The next part is called a URI, which is similar to a URL; this is the root of the debian directory. After the URI comes the distribution, which is generally listed as “stable”, “frozen” or “unstable”, although a specific distribution, like Hamm, Slink or Potato, can be used. Distribution can also be given as an exact path, in which case it needs to end with a “/”, and no components can be specified. Components are usually “main”, “contrib”, “non-free”, “non-us/main”, “non-us/contrib” or “non-us/non-Free”. That's about all you need to know to take advantage of sources.list. CD-ROM entries are generated by apt-cdrom (more on this later), so you don't need to write those by hand.

Editing the source.list file is done to change the sites APT uses (changing mirrors), to change which distribution APT will be getting packages from, or simply to add new URIs for “unofficial” debs, or sites which maintain newer debs, like KDE and HelixCode, respectively. After editing this file, you should always run apt-get update. For a listing of Debian mirrors to use, check http://www.debian.org/.

apt-cdrom

One way to add your Debian CD-ROMs to APT's database is with the remarkably easy-to-use apt-cdrom. The command apt-cdrom add should automatically mount your CD-ROM (provided /dev/cdrom is correctly linked), scan it and create the correct entry in /etc/apt/sources.list.

As with anything in Linux, that's not the only way to do it! If your Debian CD-ROM is mounted (the mount point must be listed in /etc/fstab), you can use a few flags to accomplish the task. Use -d <mount point> to specify the mount point,-f to make apt-cdrom not check the individual packages, and -a for a thorough package scan that will look for package files everywhere on the CD-ROM.

apt-get

Debian's greatest claim to fame is apt-get, an incredibly smart (okay, smart most of the time), easy-to-use package tool that automatically deals with package dependencies and conflicts. The first thing you should do (and do it every time you edit /etc/apt/sources.list) is run apt-get update, which pulls the package information used by apt-cache and apt-get from these locations.

Now, you can go about installing packages. APT's most used action is probably install. To install a new package (and automatically meet its dependencies), use apt-get install <package>. If there are other packages that must be installed, APT will let you know before downloading them.

If you install a deb without meeting the requirements, or a problem is encountered during install or removal, you will often be unable to work with dpkg until the problem is resolved. One method to use for solving these problems is the command apt-get -f install, which will try to work everything out and ask questions as it goes along.

APT can also download sources with apt-get source <package> if you have any deb-src lines in your /etc/apt/sources.list. To remove packages, use apt-get remove <package>. If you want to clean out the archives, there are two options. To remove all archives, the command is apt-get clean; if you only want to remove old archives, use apt-get autoclean instead. When the time comes to upgrade all packages to their latest version, one easy command, apt-get upgrade, will take care of it. Meanwhile, apt-get dist-upgrade is suited for upgrading to a new version of Debian, automatically reconfiguring dependencies for packages whose names have changed.

A few other command-line options are helpful when using apt-get: “-d” only downloads archives but doesn't try to install or unpack them; “-s” for simulation, it won't actually do anything; “y” answers yes to all questions; and “-b” tries to build a source package after downloading it.

Additionally, apt-get can use regular expression patterns such as apt-get install '.*mame.*' or apt-get remove 'mozill.'. Apt-get will also try to match an element appearing at a specific point in the string. For example, to match “pilot” only in the beginning position, like “pilot-manager” and not “gnome-pilot”, use “^” (which is the “beginning of line” character) in an expression like apt-get install '^pilot.*'.

______________________

White Paper
Fabric-Based Computing Enables Optimized Hyperscale Data Centers

Today’s modular x86 servers are compute-centric, designed as a least common denominator to support a wide range of IT workloads. Those generic, virtualized IT workloads have much different resource optimization requirements than hyperscale and cloud applications. They have resulted in a “one size fits all” enterprise IT architecture that is not optimized for a specific set of IT workloads, and especially not emerging hyperscale workloads, such as web applications, big data, and object storage. In this report, you will learn how shifting the focus from traditional compute-centric IT architectures to an innovative disaggregated fabric-based architecture can optimize and scale your data center.

Learn More

Sponsored by AMD

White Paper
Red Hat White Paper: Using an Open Source Framework to Catch the Bad Guy

Built-in forensics, incident response, and security with Red Hat Enterprise Linux 6

Every security policy provides guidance and requirements for ensuring adequate protection of information and data, as well as high-level technical and administrative security requirements for a system in a given environment. Traditionally, providing security for a system focuses on the confidentiality of the information on it. However, protecting the data integrity and system and data availability is just as important. For example, when processing United States intelligence information, there are three attributes that require protection: confidentiality, integrity, and availability.

Learn more about catching the bad guy in this free white paper.

Learn More

Sponsored by DLT Solutions