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.
Starting the interactive interface
Run aptitude without a subcommand:
aptitudeFor operations that change system packages, start it with suitable administrative privileges when required:
sudo aptitudeThe 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
Updating package metadata interactively
Before installing or upgrading, refresh the package lists so aptitude knows which versions are available from the configured repositories.
- Launch aptitude with
sudo aptitudeif administrative access is needed. - Press
u. - 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.
- Press
/. - Enter
nmap. - 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
- Start aptitude:
sudo aptitude- Press
uto refresh package information. - Press
/, enternmap, and locate thenmappackage. - With
nmapselected, press+to mark it for installation. - Press
gto open the pending-action review. - Inspect the package to be installed and any dependencies aptitude proposes.
- 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
- Launch aptitude and press
uto refresh package lists. - Press
Uto mark all packages for which upgrades are available. - Press
gto review the upgrade plan. - Check the packages that will be upgraded, installed, or removed.
- 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
- Find
nmapin the package list, using/if necessary. - Select the installed
nmappackage. - Press
-to mark it for removal. - Press
gto review the queued removal and any related dependency changes. - 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 nmapThe 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 updateThis updates local package lists but does not install newer versions of already installed packages.
Install a package
Install nmap with:
sudo aptitude install nmapRead 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-upgradeBecause 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 cleanUse this when cache files consume unnecessary disk space and you no longer need the downloaded archives.
Command-line task reference
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
sudoor 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:
updaterefreshes information, whileinstalland 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
aptitudewithout a subcommand opens its interactive interface. - In interactive mode,
uupdates metadata,/searches,+installs,-removes,Umarks upgrades, andgreviews and applies queued actions. - Command-line mode uses subcommands such as
search,update,install,full-upgrade, andclean. - Always inspect dependency changes and proposed removals before confirming package operations.