Intro to managing packages on Debian GNU/Linux using 

http://anarka.org/linux/debian_pkgmanager.php

dpkg(Good), apt(Better) and aptitude(Best)

dpkg 

apt 

aptitude 

aptitude is based on apt so most of the functions are the same as in apt, but it combines apt-get and apt-cache into the same program with some some new features.

Update package list:

aptitude update

Upgrade all installed packages:

aptitude upgrade

Upgrade all installed packages but be more agressive on resolving dependecies, can remove and install new packages. It's also used to upgrade from a distribution to another(say from stable to testing):

aptitude dist-upgrade

Install packages:

aptitude install package

Remove packages:

aptitude remove package

Purge:

aptitude purge package

See the changelog of a package, in this case we will check the changelog of gnome-games in experimental:

aptitude changelog gnome-games/experimental

As in apt, aptitude can also handle several packages at the same time, for instance:

aptitude install package1 package2 package3

aptitude search is a bit different…

Search for packages that include the string gnome(for example) in their name:

aptitude search gnome

Search for packages than include gnome in their description:

aptitude search ~dgnome

You can also search by version ~V, maintainer ~m, etc.

To list all installed packages:

aptitude search ~i

Or to list all installed packages that contain gnome on their name:

aptitude search ~ignome

Check for packages available on experimental(as long as you have a source for it):

aptitude search ~Aexperimental

List removed packages that weren't purged, their configurations still exist on your system:

aptitude search ~c

If you want to delete ALL those configs do:

dpkg --get-selections | awk '/deinstall$|purge$/{print $1}' |xargs dpkg -P

One of the new features,of aptitude, is logging every action, the logs are kept in /var/log/aptitude.

Thanks to logging package management is more efficient, it removes dependencies when you remove the package that installed them. That is great for metapackages (a metapackage is a list of packages needed for a certain task)

For example let's remove gnome-games, with apt we would get the following:

sueca:/home/anarka# apt-get --purge remove gnome-games
Reading package lists... Done
Building dependency tree... Done
The following packages will be REMOVED:
  gnome-games*
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
Need to get 0B of archives.
After unpacking 1697kB disk space will be freed.
Do you want to continue [Y/n]?

Nice gnome-games package is removed but nothing else, now let's try with aptitude:

sueca:/home/anarka# aptitude purge gnome-games
Reading package lists... Done
Building dependency tree... Done
Reading extended state information
Initializing package states... Done
Reading task descriptions... Done
Building tag database... Done
The following packages are unused and will be REMOVED:
  gnome-games-data [1:2.12.1-1] gnome-games-extra-data [2.12.0-1] guile-1.6-libs [1.6.7-1.1]
  libguile-ltdl-1 [1.6.7-1.1] libqthreads-12 [1.6.7-1.1] librsvg2-common [2.12.7-1]
The following packages will be REMOVED:
  gnome-games{p} [1:2.12.1-1]
0 packages upgraded, 0 newly installed, 7 to remove and 0 not upgraded.
Need to get 0B of archives. After unpacking 22.2MB will be freed.
Do you want to continue? [Y/n/?] n

This is much more efficient, not only it removes gnome-games, but it also removes packages that aren't needed anymore due to the removal of the package. Of course if you want good results you should only use aptitude, since apt doesn't log anything, so you can't just hope aptitude will know what you did with apt.

If you want to customize apt or aptitude use /etc/apt/apt.conf, i have the following lines in there:

APT::Default-Release unstable;
APT::Get::Show-Upgraded "true";
APT::Acquire::Retries "5";
APT::Cache-Limit 22582912;
APT::Get::Purge;
Aptitude::CmdLine::Show-Versions "true";
Aptitude::CmdLine::Verbose "5";
Aptitude::CmdLine::Always-Prompt "true";
Aptitude::CmdLine::Package-Display-Format "%c%a%M %p# %15v %15V - %d#";

Updated in 2006/07/23 anarka@anarka.org