Linux online course

Manage Debian Packages with aptitude

Learn to use aptitude interactively and from the command line to search, install, upgrade, remove, and clean Debian packages.

aptitude is a package-management frontend for APT (the Advanced Package Tool). It is used on Debian and Debian-derived distributions to retrieve, resolve, install, upgrade, and remove software packages.

aptitude has two operating modes:

  • Interactive mode: a menu-driven text interface for browsing packages and queuing operations.
  • Command-line mode: explicit actions such as update, search, install, full-upgrade, and clean.

Its common package-management tasks are conceptually similar to apt-get and other APT clients. The commands are not interchangeable in every detail, but the same APT package data and dependency-resolution concepts apply.

This lesson assumes basic terminal use, familiarity with sudo, and a general understanding of software repositories. For related command-line fundamentals, see Show the Full Path of Shell Commands.

Package-management concepts

TermMeaning
PackageA versioned archive containing software, metadata, and installation information.
RepositoryA configured source of package metadata and package files.
Package listLocally stored metadata describing packages available from configured repositories.
Installed packageA package currently installed on the system.
Available packageA package described by the local package lists, whether or not it is installed.
DependencyAnother package required for a package to function or be installed.
UpgradeReplacing an installed package with a newer version, when one is available.
RemovalUninstalling a package. This is distinct from deleting downloaded package archives.
Package cacheLocally downloaded package archive files retained after packages are obtained or installed.

Before installing or upgrading, refresh the package lists. A refresh downloads current repository metadata; it does not by itself install or upgrade software. Without a recent refresh, aptitude may not know about new package versions or may fail to find a package that is available in a configured repository.

In interactive mode, marking selects an operation for later execution. Marking a package for installation, removal, or upgrade does not immediately change the system. The queued operations are applied only after you review them and confirm the operation.

Starting the interactive aptitude interface

aptitude

Running aptitude without a subcommand opens its text-based interface. The display normally contains package categories, a package listing, status information, and a command or help area.

  • Use the arrow keys to move through categories and package entries.
  • Expand or collapse categories to browse their packages.
  • Use the search command to locate a package by name or expression.
  • Mark operations on selected packages, then review the pending-action summary.
  • Use the apply action to download and execute the queued changes.

Administrative operations may require elevated privileges. If the interface cannot perform a system change because of permissions, start it with sudo aptitude, or follow the privilege prompt provided by the system.

Interactive aptitude keyboard shortcuts

KeyActionWhen to use it
uRefresh available package listsBefore searching for newly available packages or checking upgrades.
/Search for a packageTo find a package by name or search expression.
+Mark a package for installationAfter selecting a package to install.
-Mark a package for removalAfter selecting an installed package to uninstall.
UMark upgradable packages for upgradeAfter refreshing package lists and checking available upgrades.
gReview and then apply queued package actionsAfter marking changes and before committing them.

Keyboard shortcuts are case-sensitive. In particular, lowercase u refreshes package information, while uppercase U marks eligible installed packages for upgrade.

Install nmap interactively

nmap is a network-scanning utility and a useful example package.

  1. Open the interface with aptitude, using elevated privileges if required.
  2. Press lowercase u to refresh package information. Wait for the update to finish.
  3. Press /, enter nmap, and submit the search.
  4. Select the intended nmap package in the results.
  5. Press + to mark it for installation. Aptitude may also mark dependencies needed by nmap.
  6. Press g to display the proposed actions.
  7. Review package names, versions, downloads, and any removals or replacements. Confirm only when the plan is understood.
  8. Continue through the confirmation prompt to download and install the package.

The package is not installed when you press +; that only queues the operation. The actual installation begins during the g apply step.

Upgrade packages interactively

  1. Open aptitude and press lowercase u to refresh repository package lists.
  2. Press uppercase U to mark all eligible installed packages for upgrade.
  3. Press g to review the proposed upgrade plan.
  4. Inspect the versions, dependencies, downloads, and any package additions, replacements, or removals.
  5. Confirm the plan to apply the upgrades.

Remove nmap interactively

  1. Open aptitude and locate the installed nmap package by browsing or pressing / and searching for nmap.
  2. Select the installed package entry and press - to mark it for removal.
  3. Press g to review the pending removal and any related dependency changes.
  4. Confirm the operation to apply the removal.

Removing nmap uninstalls the package, but it does not necessarily delete downloaded package archives from the local cache. Cleaning cached archives is a separate operation.

Using aptitude from the command line

The general command form is:

aptitude ACTION [PACKAGE_NAME_OR_PATTERN]

Actions that change system packages generally require root privileges, commonly supplied through sudo.

Search for packages

aptitude search nmap

This searches available package metadata for a package name or search expression. If the results are too broad, use a more specific name or pattern.

Refresh package lists

sudo aptitude update

This downloads current metadata from configured APT repositories. It does not install updates.

Install a package

sudo aptitude install PACKAGE_NAME
sudo aptitude install nmap

Aptitude calculates dependencies and proposes the packages required to install the requested package. Review the proposal before confirming.

Perform a full upgrade

sudo aptitude full-upgrade

full-upgrade upgrades installed software while allowing dependency-related changes needed to complete the operation. Compared with a conservative upgrade, it may add, replace, or remove packages.

Clean downloaded package archives

sudo aptitude clean

clean deletes downloaded package archive files from the local package cache. It does not uninstall currently installed software. Cached archives can be useful for reinstalling without downloading again, so clean them when reclaiming disk space is more important than retaining those files.

Interactive actions versus command-line commands

GoalInteractive methodCommand-line method
Refresh package metadataPress usudo aptitude update
SearchPress /, then enter a name or patternaptitude search PACKAGE_NAME
InstallSelect a package, press +, then press g to applysudo aptitude install PACKAGE_NAME
UpgradePress U, then press g to applysudo aptitude full-upgrade
RemoveSelect an installed package, press -, then press g to applysudo aptitude remove PACKAGE_NAME
Clean package cacheUse the interface's package-cache cleanup action, if availablesudo aptitude clean

Verify package operations

After installing a package, query its installed state:

aptitude search '^nmap$'

An installed package is normally shown with an installed-state marker in the search output. You can also ask aptitude to display package details:

aptitude show nmap

For a more direct Debian package database check, use:

dpkg-query -W -f='${Status}\n' nmap

A successful installed result contains install ok installed. After an upgrade, run the same package query or inspect the installed version with aptitude show PACKAGE_NAME. After removal, confirm that the package no longer appears as installed.

Troubleshooting

A package cannot be found

  • Refresh the package lists with sudo aptitude update or interactive u.
  • Check that the package name is spelled correctly; try a broader search expression.
  • Check whether the repository containing the package is enabled in the system's configured APT software sources.

Marked changes do not happen immediately

Marking queues an operation; it does not commit it. Press g, inspect the action summary, and confirm the apply step.

Dependency conflicts are reported

Conflicts can result from incompatible requested versions, held packages, obsolete packages, or mixed repositories. Read the proposed solution carefully. Do not accept removals or replacements unless you understand their effect. Refresh the package lists and reassess the requested packages if the proposal is unexpected.

A command reports permission denied

Package installation, removal, upgrades, and cache cleanup modify system files. Run the command with sudo, such as sudo aptitude install nmap, or use an administrator account.

Disk space remains low

Downloaded package archives may still occupy space in the package cache. After checking that you do not need those archives for offline reuse, run:

sudo aptitude clean

This removes cached archive files without uninstalling software that is already installed.

Exam-relevant summary

  • aptitude is an APT frontend for Debian and Debian-derived systems.
  • Running aptitude opens an interactive text interface; explicit actions use command-line mode.
  • Refresh package lists before searching, installing, or checking upgrades.
  • Interactive marks are queued changes; g reviews and applies them.
  • Lowercase u updates package lists, while uppercase U marks upgrades.
  • full-upgrade can change dependencies by adding, replacing, or removing packages.
  • clean deletes downloaded package archives; it does not remove installed software.