aptitude
is an interactive program that can be used in semi-graphical mode on the console. You can browse the list of installed and available packages, look up all the available information, and select packages to install or remove. The program is designed specifically to be used by administrators, so that its default behaviors are much more intelligent than
apt-get
's, and its interface much easier to understand.
When it starts,
aptitude
shows a list of packages sorted by state (installed, non-installed, or installed but not available on the mirrors — other sections display tasks, virtual packages, and new packages that appeared recently on mirrors). To facilitate thematic browsing, other views are available. In all cases,
aptitude
displays a list combining categories and packages on the screen. Categories are organized through a tree structure, whose branches can respectively be unfolded or closed with the
Enter,
[ and
] keys.
+ should be used to mark a package for installation,
- to mark it for removal and
_ to purge it (note than these keys can also be used for categories, in which case the corresponding actions will be applied to all the packages of the category).
u updates the lists of available packages and
Shift+
u prepares a global system upgrade.
g switches to a summary view of the requested changes (and typing
g again will apply the changes), and
q quits the current view. If you are in the initial view, this will effectively close
aptitude
.
To search for a package, you can type
/ followed by a search pattern. This pattern matches the name of the package, but can also be applied to the description (if preceded by
~d
), to the section (with
~s
) or to other characteristics detailed in the documentation. The same patterns can filter the list of displayed packages: type the
l key (as in
limit) and enter the pattern.
6.4.1.1. Tracking Automatically Installed Packages
One of the essential functionnalities of
aptitude
(which has also been integrated to
apt-get
since
Lenny) is the tracking of packages installed only through dependencies. These packages are called “automatic” and are tagged with an “A” in the list of packages — they often include libraries for instance. When a package is removed, the corresponding automatic packages are also selected for removal unless another “manually installed” package depends on them. It is possible to mark a package as automatic (with
Shift+
m) or to remove the mark (
m key). When maintaining a system with
aptitude
, it is a good habit to mark as automatic any package that you don't need directly so that they are automatically removed when they aren't necessary anymore. You can either navigate the list of installed packages and play with
Shift+
m, or apply the flag to entire sections (for example the
libs
section). This habit can help you to keep your system tidy and offers a simple way to visualize the packages in use on a machine, without all the libraries and dependencies that you don't really care about. The related pattern that can be used with
l (to activate the filter mode) is
~i!~M
. It specifies that you only want to see installed packages (
~i
) not marked as automatic (
!~M
).
People might want to know why an automatically installed package is present on the system. To get this information from the command-line, you can use
aptitude why package
:
$
aptitude why python-debian
i aptitude Recommends apt-xapian-index
i A apt-xapian-index Depends python-debian (>= 0.1.15)
6.4.1.2. Managing Recommendations, Suggestions and Tasks
Another interesting feature of
aptitude
is the fact that it respects recommendations between packages while still giving users the choice not to install them on a case by case basis. For example, the
gnome-desktop-environment package recommends
gnome-accessibility (among others). When you select the former for installation, the latter will also be selected (and marked as automatic if not already installed on the system). Typing
g will make it obvious:
gnome-accessibility appears on the summary screen of pending actions in the list of packages installed automatically to satisfy dependencies. However, you can decide not to install it by deselecting it before confirming the operations.
Note that this recommendation tracking feature does not apply to upgrades. For instance, if a new version of
gnome-desktop-environment recommends a package that it did not recommend formerly, the package won't be marked for installation. However, it will be listed on the upgrade screen so that the administrator can still select it for installaion.
Suggestions between packages are also taken into account, but in a manner adapted to their specific status. For example, since
gnome-desktop-environment suggests
gnome-audio, the latter will be displayed on the summary screen of pending actions (in the section of packages suggested by other packages). This way, it is visible and the administrator can decide whether to take the suggestion into account or not. Since it is only a suggestion and not a dependency or a recommendation, the package will not be selected automatically — its selection requires a manual intervention from the user (thus, the package will not be marked as automatic).
In the same spirit, remember that
aptitude
makes intelligent use of the concept of task. Since tasks are displayed as categories in the screens of package lists, you can either select a full task for installation or removal, or browse the list of packages included in the task to select a smaller subset.
6.4.1.3. Better Solver Algorithms
To conclude this section, let's note that
aptitude
has more elaborate algorithms compared to
apt-get
when it comes to resolving difficult situations. When a set of actions is requested and when these combined actions would lead to an incoherent system,
aptitude
evaluates several possible scenarios and presents them in order of decreasing relevance. However, these algorithms are not failproof. Fortunately there is always the possibility to manually select the actions to perform. When the currently selected actions lead to contradictions, the upper part of the screen indicates a number of “broken” packages (and you can directly navigate to those packages by pressing
b). It is then possible to manually build a solution for the problems found. In particular, you can get access to the different available versions by simply selecting the package with
Enter. If the selection of one of these versions solves the problem, you should not hesitate to use the function. When the number of broken packages gets down to zero, you can safely go the summary screen of pending actions for a last check before you apply them.