Little-known APT utilities for Debian desktop users

141

Author: Bruce Byfield

The Advanced Packaging Tool (APT) is a distinguishing feature of Debian-based systems. APT was the first major alternative in GNU/Linux to boast automatic dependency resolution. Most GNU/Linux users know it through the apt-get command, a utility that calls on the lower-level dpkg command. However, other APT-based utilities remain largely unknown to desktop users. Some of these utilities offer a range of functionality far beyond those of the basic tools.

These functions include setting up package sources (apt-cdrom and apt-spy), querying package information (apt-cache and apt-rdepends), extracting the latest list of bugs associated with a package (apt-listbugs), and receiving automatic updates (apt-watch). Many can be run from any account; you need the root account only for the final stages of configuration or the installation and removal of packages.


apt-cdrom and apt-spy

Debian package management depends on a list of online repositories in /etc/apt/source.list. Usually, this list consists of FTP and HTTP URLs, but, if you have a recent collection of Debian CDs, or want to install on a computer unconnected to the Internet, you can use apt-cdrom to add a CD/DVD source temporarily, using the syntax apt-cdrom add device while logged in as the root user. You need to enter the command for each CD/DVD that you use.

For online sources, many users rely on either the closest mirror or the basic Debian repositories. However, despite conventional wisdom, neither may be the fastest source available. The apt-spy command provides you the benchmarks to find the fastest mirror available. You need to specify the Debian distribution to use — stable, testing, or unstable — and, in the interest of saving time, you probably want to specify either the region or the country as well. For example, if you entered apt-spy -dtesting -anorth-america, the utility would check the speed for testing repositories in North America. Download speeds for FTP and HTTP URLs are given separately in the output as each repository is tested. If you choose, you can also specify a list of mirrors to test using apt-spy, an output file (which is useful if you want to compare results), and the size of the file and the length of time that apt-spy spends waiting for a response from each source.

Probably, if you really want to be sure that you have the fastest repositories in your sources.list, you’ll want to run apt-spy several times, preferably at different times of day. Be warned, though, that even when the conditions you use are well-defined, you’ll still need five or 10 minutes for apt-spy to complete each run. Unless you regularly do massive upgrades or installation, you may not find that you’ll save enough time to justify running apt-spy in the first place.


apt-cache and rdpends

Before installing packages, experienced Debian users may want to learn as much as possible about the packages they are installing. One way to check this information is through the Debian Packages page, but that page is so heavily used that it is often slow, and sometimes crashes for hours or even days at a time.

Instead, experienced users rely on apt-cache and its series of commands. Typing apt-cache showpkg packagename from any account will give information about a package’s current version and the latest version available from the repositories in sources.list, as well as the package’s dependencies and its reverse dependencies — that is, the packages dependent on it. You can also get dependency information using apt-cache depends packagename or with apt-rdepends. Similarly, apt-cache dump gives a list of all installed packages, and apt-cache stats reports detailed statistics about installed packages as a whole. And if you want to check whether a package is available, then apt-cache --full search packagename can give you the answer, complete with the available version, MD5 sum, and encryption keys. If you have trouble remembering the exact package name, you can enter regular expressions to expand your search.


apt-listbugs

For the truly cautious, the information provided by apt-cache can be supplemented by apt-listbugs list packagename, which searches the Debian Bug Tracking System and summarizes the results. Using the -l option lists bugs for packages already installed on your system. You can also use the -s option to set the level of bugs that you want to know about, or run scenarios in which you assume that you answer yes or no to all configuration questions to see which bugs can emerge. For anyone who regularly dips into the unstable repositories, apt-listbugs can become a routine program to run before anything but the simplest installation or upgrade.


apt-watch

Another useful package is apt-watch, a GNOME applet that automates updates. Like most Debian packages, apt-watch comes with a wealth of configuration options. You can set how regularly the applet checks for updates, and whether it automatically installs all new packages, only security updates, or none at all. You can set notifications for similar options. And, while apt-watch works by default with the Synaptic graphical interface for apt-get, you can set it to use apt-get, Aptitude, or any other interface you prefer.

Running apt-watch is a matter of selecting commands from the right-click menu. The applet as a rotating Debian logo while checking for updates, and becomes a light bulb when updates are available.

While apt-watch may not satisfy those who run apt-get upgrade from their daily crontab, for most users it provides a convenient way to keep track of updates, even if you use it only for notification of what’s available. However, unless your sources.list is set to only the stable distribution, you should be cautious that too much automation doesn’t leave you with broken dependencies and fumbling to regain the ability to manage packages.


Other apt utilities

These are only a sampling of the available apt utilities, chosen mainly for their usefulness to desktop users. Those interested in building a Debian installer might want to look at apt-mirror-setup, while those who build .deb packages should find apt-utils convenient tools. Similarly, those who need to update a Debian installation through a network server might want to look at apt-proxy.

Even further afield from everyday concerns, apt-rpm-repository is available for creating a repository of .rpm packages on a Debian system. Still another utility is apt-build, which creates a local repository of source packages to help in the building of an optimized system.

With so many utilities available, if you are using only apt-get and dpkg on your Debian system, you’re not taking advantage of all that package management has to offer.

Bruce Byfield is a course designer and instructor, and a computer journalist who writes regularly for NewsForge, Linux.com and IT Manager’s Journal.

Category:

  • Linux