VMware ESXi and vSphere Cluster Management

Manage Debian Packages with aptitude

Learn to use aptitude's interactive terminal interface and command-line mode to search, install, upgrade, remove, and clean packages on Debian-based Linux systems.

aptitude is a terminal-based frontend for APT, the Advanced Package Tool ecosystem used by Debian and Debian-based Linux distributions. A package is a distributable unit of software and metadata managed by the package system.

aptitude can display installed packages and packages available from configured package repositories. It can also install, upgrade, remove, and clean packages. It provides two modes: an interactive, menu-driven terminal interface and a command-line mode using subcommands.

How aptitude and APT fit together

APT retrieves package information and package files from configured repositories and resolves dependencies. A dependency is another package required by a selected package to work or to be installed. aptitude provides an interface for requesting these operations and reviewing the resulting dependency plan.

A locally downloaded package list is repository metadata that tells the system which package versions are available. The package list is separate from the software already installed on the computer, so refreshing it does not automatically upgrade anything.

Interactive mode versus command-line mode

ModeBest forHow actions are selectedHow changes are applied

Interactive mode — Browsing packages and reviewing a visual plan — Menu navigation and keyboard shortcuts — Actions are marked first, then reviewed and executed

Command-line mode — Repeatable tasks, scripts, and quick operations — A subcommand and optional package arguments — The requested operation is planned and normally confirmed in the terminal

Starting the interactive interface

Run aptitude without a subcommand:

aptitude

For operations that change system packages, start it with suitable administrative privileges when required:

sudo aptitude

The interface presents a package list along with menu areas and status information. Use the keyboard to move through package groups and entries. Select a package, mark an action, inspect the proposed changes, and then execute the queue.

Interactive aptitude key reference

KeyActionTypical use

u — Refresh package lists — Download current metadata from configured repositories

/ — Search for a package — Find a package by name or another search term

+ — Mark a package for installation — Queue the selected package and required dependencies

- — Mark a package for removal — Queue removal of the selected package

U — Mark all upgradeable packages for upgrade — Queue available upgrades

g — Review and execute queued package actions — Inspect the plan, then start downloads and changes

Updating package metadata interactively

Before installing or upgrading, refresh the package lists so aptitude knows which versions are available from the configured repositories.

  1. Launch aptitude with sudo aptitude if administrative access is needed.
  2. Press u.
  3. Wait for aptitude to contact the repositories and update its local metadata.

Updating package lists only refreshes information. It does not upgrade installed packages. To upgrade software, you must separately mark upgrades and apply them.

Searching for packages interactively

Press / to open the search function, enter a package name or search term, and submit the query. For example, search for nmap, a network-scanning utility used in the examples below.

  1. Press /.
  2. Enter nmap.
  3. Move through the matching results and select the package named nmap.

Read the package description and status information before selecting an action. A search result can represent an installed package, an available package, or a package with a different version available from a repository.

Installing nmap interactively

  1. Start aptitude:
sudo aptitude
  1. Press u to refresh package information.
  2. Press /, enter nmap, and locate the nmap package.
  3. With nmap selected, press + to mark it for installation.
  4. Press g to open the pending-action review.
  5. Inspect the package to be installed and any dependencies aptitude proposes.
  6. Confirm the operation when the plan is correct. aptitude then downloads and installs the package.

Reviewing the queue is useful because installing one package can require additional dependency packages. If the proposed plan is unexpected, cancel or revise the marks before confirming.

Upgrading packages interactively

  1. Launch aptitude and press u to refresh package lists.
  2. Press U to mark all packages for which upgrades are available.
  3. Press g to review the upgrade plan.
  4. Check the packages that will be upgraded, installed, or removed.
  5. Confirm the plan to apply the upgrade.

A full upgrade can involve dependency-driven changes. Do not confirm until proposed removals and new installations are understood.

Removing nmap interactively

  1. Find nmap in the package list, using / if necessary.
  2. Select the installed nmap package.
  3. Press - to mark it for removal.
  4. Press g to review the queued removal and any related dependency changes.
  5. Confirm the operation only if the complete plan is acceptable.

Removing a package can affect other packages when they depend on it. Always inspect the proposed actions instead of assuming that only one package will change.

Using aptitude from the command line

Command-line mode uses a general pattern consisting of the aptitude command, a subcommand, and optional package names:

aptitude SUBCOMMAND [PACKAGE_NAME ...]

It covers many workflows commonly associated with apt-get and is useful when you already know the operation you want to perform.

Search for packages

Use search with a package-name query:

aptitude search nmap

The output lists matching package entries and descriptions. If the desired package is not found, check the spelling, refresh package metadata, try a broader search term, and verify that an appropriate repository is configured.

Update package indexes

Refresh metadata from configured repositories:

sudo aptitude update

This updates local package lists but does not install newer versions of already installed packages.

Install a package

Install nmap with:

sudo aptitude install nmap

Read aptitude's proposed package changes and confirm only when the dependency plan is appropriate.

Perform a full upgrade

A full upgrade may install or remove packages when necessary to complete dependency changes:

sudo aptitude full-upgrade

Because this operation can make several related changes, review the proposed actions carefully before confirming.

Clean downloaded package archives

The package cache can retain downloaded package archives. Remove those cached archives with:

sudo aptitude clean

Use this when cache files consume unnecessary disk space and you no longer need the downloaded archives.

Command-line task reference

TaskCommand patternResult

Search packages — aptitude search PACKAGE_NAME — Finds matching package names and descriptions

Update package metadata — sudo aptitude update — Refreshes repository package lists

Install a package — sudo aptitude install PACKAGE_NAME — Installs the named package and required dependencies

Perform a full upgrade — sudo aptitude full-upgrade — Upgrades packages and may install or remove packages to resolve dependencies

Clean downloaded package archives — sudo aptitude clean — Removes downloaded package files from the local cache

Safety and review practices

  • Refresh package lists before relying on search results, installations, or upgrade decisions.
  • Inspect proposed installs, upgrades, removals, and dependency changes before confirming.
  • Remember that system-wide package changes normally require sudo or another administrative privilege mechanism.
  • Use extra care with full-upgrade, because dependency resolution can require package additions or removals.
  • Do not confuse repository metadata with installed software: update refreshes information, while install and upgrade operations change packages.

Troubleshooting aptitude

aptitude is not installed

If the shell reports that aptitude cannot be found, the utility may not be installed, or the system may not use Debian's APT packaging ecosystem. Verify that the distribution is Debian-based and install aptitude using an available package-management method before continuing.

A package cannot be found

Stale metadata, an incorrect package name, or a missing repository can cause this symptom. Run sudo aptitude update, verify the spelling, search with a broader term, and check the configured software sources.

Permission errors occur

Package-changing operations need administrative privileges. Retry the command with an appropriate privilege elevation method, commonly sudo.

An upgrade proposes surprising removals or installations

Package version transitions and dependency relationships may require related changes. Review the complete plan and do not proceed until the proposed dependency changes are understood.

The package cache uses too much disk space

Previously downloaded archives may remain in the local cache. After confirming that they are not needed, run sudo aptitude clean.

Key points to remember

  • aptitude is an APT frontend for Debian and Debian-based systems.
  • Running aptitude without a subcommand opens its interactive interface.
  • In interactive mode, u updates metadata, / searches, + installs, - removes, U marks upgrades, and g reviews and applies queued actions.
  • Command-line mode uses subcommands such as search, update, install, full-upgrade, and clean.
  • Always inspect dependency changes and proposed removals before confirming package operations.