Comparing the apt-get and aptitude package tools

Slashdot it! Delicious Share on Facebook Tweet! Digg!

Subcommands and Parameters

Table 1 shows some differences between apt-get and aptitude subcommands. You'll see some differences between subcommands of the same name in both tools. This is especially true of upgrade , safe-upgrade , dist-upgrade , and full-upgrade , so they are treated separately elsewhere (see the "Subtle Differences" box). Further information is in the aptitude manual [7] and the man pages for apt-get and aptitude.

Subtle Differences

The full-upgrade and dist-upgrade subcommands are differentiated by their varying algorithms to resolve package dependencies. Apt-get even allows swapping of algorithms.

The apt-get upgrade command upgrades packages that can be upgraded without having to deinstall others or set up uninstalled ones. In contrast, aptitude safe-upgrade upgrades all packages that can be upgraded without having to remove manually installed ones. The --no-new-installs option makes aptitude safe-upgrade comparable with apt-get upgrade .

However, there's a big difference between apt-get upgrade/dist-upgrade and aptitude safe-/full-upgrade . Aptitude's subcommands take package names as subsequent parameters, in which case, the package manager tries to upgrade only the specified packages, under the conditions of the subcommand.

Well Considered

Somewhat hidden is the possibility of not directly executing actions with aptitude but scheduling them for later execution. The software works on these scheduled actions as soon as it hits other actions at a later point, such as installing, removing, or updating packages.

The order in which aptitude executes the scheduled actions cannot always be predicted. It depends largely on the dependencies among the packages that need to be considered in single actions. Additionally, later actions can revise earlier ones. Aptitude stores the action status of packages in an internal database (see the box titled "Aptitude's Status Database"). Any packages that are earmarked to fulfill dependencies are marked as "automatically installed" with the letter A in the user interface.

Aptitude's Status Database

Aptitude maintains its auxiliary data for packages in a text-based database in /var/lib/aptitude/pkgstates . A package entry consists of five lines; for example, for the debtree package, the entry would be:

Package: debtree
Unseen: no
State: 1
Dselect-State: 1
Remove-Reason: 0

Package contains the package name, Unseen stores whether the package shows up in aptitude's list of new packages because it was "not yet seen," and State contains the package status (where 1 means "installed," 2 is "retained," 3 is "not yet installed," and 4 is "removed, but configuration files preserved"). Dselect-State indicates whether holds apply, and Remove-Reason indicates the reason why the package might be removed automatically – either it was no longer needed or it conflicted with other packages.

Apt can also deal with these markers and sets them when installing packages. If apt-get discovers packages marked as automatically installed but no other package depends on them, it will inform you.

You execute package actions with aptitude on the command line or in the interactive text mode interface. In the text-mode interface, practically every package marking (+ for installation or for removal) is a scheduled action. If you press g , you will see previews of held packages in the standard configuration.

Pressing g again executes the held action. Pressing q stops aptitude, but it remembers the previously planned package actions for the next call. Pressing Ctrl+C stops aptitude without storing the actions.

You can get the same result on the command line by including the --schedule-only option in an aptitude call. Performing a subsequent aptitude install , without further parameters, is enough to execute all the scheduled actions (see Listing 1).

Listing 1

Aptitude Commands

# aptitude --schedule-only install htop
# aptitude --schedule-only remove tasksel
# aptitude install
The following NEW packages will be installed:
The following packages will be REMOVED:
  tasksel tasksel-data{a}
0 packages upgraded, 1 newly installed, 2 to remove and 0 not upgraded.

It's often helpful to find out before installing which held packages are affected. The easiest way is to simulate the action by activating the -s or --simulate option, as in aptitude install -s . In interactive mode, you would first select the package with + , and then press g for the preview (Figure 2).

Figure 2: Aptitude shows the selected package as libreoffice-common. Pressing g proceeds with the upgrade.

To cancel scheduled actions, aptitude provides the subcommand keep-all . If you simply want to undo a single package, you can use the subcommand keep , such as in aptitude --schedule-only keep tasksel . In interactive mode, you can press Shift+: (Shift+; for US-American keyboard layout) after selecting the package. To undo the last scheduled action, press Ctrl+U in interactive mode.

Buy this article as PDF

Express-Checkout as PDF

Pages: 4

Price $0.99
(incl. VAT)

Buy Ubuntu User

Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content