This is a read-only archive. Find the latest Linux articles, documentation, and answers at the new Linux.com!

Linux.com

Feature: Linux

Little-known APT utilities for Debian desktop users

By Bruce Byfield on July 28, 2006 (8:00:00 AM)

Share    Print    Comments   

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.

Bruce Byfield is a computer journalist who writes regularly for Linux.com.

Share    Print    Comments   

Comments

on Little-known APT utilities for Debian desktop users

Note: Comments are owned by the poster. We are not responsible for their content.

Cheers

Posted by: Anonymous Coward on July 30, 2006 03:01 AM
Thanks for the article.

One unmentioned 'apt utility' that I seem to use regulary is apt-file. Very useful when you need to find out a package that provides certain file(s).

#

Re:Cheers

Posted by: Anonymous Coward on July 30, 2006 01:22 PM
I was using this, then I discovered that pretty much the smae thing can be done with packages.ubuntu.com and if they have it back up, packages.debian.org, and without the heavy load on my system.

#

how to find package install date with apt?

Posted by: Anonymous Coward on July 30, 2006 10:16 AM
Back when I used Redhat/Fedora, I could use rpm and find the install date for packages, which was very useful. Now I'm using Ubuntu, apt works great but I don't know how to find the date a package was installed on my system. Can I use apt to do this?

#

Re:how to find package install date with apt?

Posted by: Anonymous Coward on August 03, 2006 11:04 AM
This works for me:

grep "<none>"<nobr> <wbr></nobr>/var/log/dpkg.log

#

Rollback-option

Posted by: Anonymous Coward on July 30, 2006 04:27 PM
Sometimes when a package is updated the new version of the package breaks something else. On Redhat and up2date one can then roll back to the previous installed version of that package.

Is this useful feature available with Debian and apt? It's simply an undo feature.

#

Re:Rollback-option

Posted by: Anonymous Coward on July 31, 2006 10:10 PM
"the new version of the package breaks something else"<nobr> <wbr></nobr>... On Debian, I've never seen that happen. But installing a specific version of something is easy enough:
<tt>apt-get install package=version</tt>
You can also "pin" a package to a specific version, to prevent it being upgraded.

#

Re:Rollback-option

Posted by: Anonymous Coward on August 01, 2006 12:31 AM
Thanks for the advise! What I meant was that upgrades to Debian packages can break software that I've compiled myself on the system. This will help a lot, even though I have to keep track of my package versions by hand I guess.

#

Nice article

Posted by: Anonymous Coward on August 01, 2006 05:22 AM
Nice article but I more example woould have make it better.
<a href="http://www.tumujer.com/" title="tumujer.com"> </a tumujer.com><a href="http://www.tumujer.com/" title="tumujer.com">http://www.tumujer.com/</a tumujer.com>

#

Re:Nice article

Posted by: Anonymous Coward on October 02, 2006 10:38 AM
re: "I more example woould have make it better."

Sometimes I wish pr0n spammers would do the world a favor and go play dodge the cars on a busy highway going at full speed.

#

apt-cache dump

Posted by: Anonymous Coward on January 25, 2007 05:06 AM
apt-cache dump gives a list of all installed packages


Where I live, apt-cache dump gives a complete list of the package index.

ctrl-c

#

deborphan

Posted by: Administrator on July 30, 2006 08:09 PM
If you try a lot of software, installing and uninstalling packages, then after a while you'll have a lot of useless leftover dependencies installed too. Run deborphan to see a list of these. You can apt-get --purge remove `deborphan`. Now do it again, to see more packages that now turn out also to be useless. Do this until there aren't any more, and you've removed a lot of cruft from your system.

#

Re:Little-known APT utilities for Debian desktop users

Posted by: Anonymous [ip: 82.43.97.94] on January 01, 2008 04:12 PM
Is there any utility that will automatically retrieve source code for all the packages that I have installed on my system.

#

This story has been archived. Comments can no longer be posted.



 
Tableless layout Validate XHTML 1.0 Strict Validate CSS Powered by Xaraya