Aptitude is a menu-driven, text-based application to install and uninstall applications (packages). Many of the common package management functions, such as installation, removal, and upgrade, are performed in Aptitude with single-key commands (they are typically lowercase letters).
aptitude vs. apt-get: in many ways, they're the same in that they both draw from the repositories in your /etc/apt/sources.list to retrieve and install software. When you uninstall an application, only aptitude will remove the dependencies when the application is removed as of early Ubuntu 6.10. The apt-get command will remove dependencies as shown at command below. And you cannot install with apt-get or Synaptic and then expect to have dependencies removed by uninstalling with aptitude.
To remove unused dependencies when removing an application with apt-get:
sudo apt-get autoremove applicationname
Aptitude is best suited for use in a non-graphical terminal environment to ensure proper functioning of the command keys. To start Aptitude, type the following command at a terminal prompt:
When Aptitude starts, you will see a menu bar at the top of the screen and two panes below the menu bar. The top pane contains package categories, such as New Packages and Not Installed Packages. The bottom pane contains information related to the packages and package categories.
- Install Packages: To install a package, locate the package via the Not Installed Packages package category, for example, by using the keyboard arrow keys and the ENTER key, and highlight the package you wish to install. After highlighting the package you wish to install, press the + key, and the package entry should turn green, indicating it has been marked for installation. Now press g to be presented with a summary of package actions. Press g again, and you will be prompted to become root to complete the installation. Press ENTER which will result in a Password: prompt. Enter your user password to become root. Finally, press g once more and you'll be prompted to download the package. Press ENTER on the Continue prompt, and downloading and installation of the package will commence
- Remove Packages: To remove a package, locate the package via the Installed Packages package category, for example, by using the keyboard arrow keys and the ENTER key, and highlight the package you wish to remove. After highlighting the package you wish to install, press the - key, and the package entry should turn pink, indicating it has been marked for removal. Now press g to be presented with a summary of package actions. Press g again, and you will be prompted to become root to complete the installation. Press ENTER which will result in a Password: prompt. Enter your user password to become root. Finally, press g once more, and you'll be prompted to download the package. Press ENTER on the Continue prompt, and removal of the package will commence
- Update Package Index: To update the package index, simply press the u key and you will be prompted to become root to complete the update. Press ENTER which will result in a Password: prompt. Enter your user password to become root. Updating of the package index will commence. Press ENTER on the OK prompt when the download dialog is presented to complete the process.
- Upgrade Packages: To upgrade packages, perform the update of the package index as detailed above, and then press the U key to mark all packages with updates. Now press g whereby you'll be presented with a summary of package actions. Press g again, and you will be prompted to become root to complete the installation. Press ENTER which will result in a Password: prompt. Enter your user password to become root. Finally, press g once more, and you'll be prompted to download the packages. Press ENTER on the Continue prompt, and upgrade of the packages will commence.
The first column of information displayed in the package list in the top pane, when actually viewing packages lists the current state of the package, and uses the following key to describe the state of the package:
- i: Installed package
- c: Package not installed, but package configuration remains on system
- p: Purged from system
- v: Virtual package
- B: Broken package
- u: Unpacked files, but package not yet configured
- C: Half-configured - Configuration failed and requires fix
- H: Half-installed - Removal failed and requires fix
To exit Aptitude, simply press the q key and confirm you wish to exit.
Aptitude can also be used with terminal parameters. All the list:
Usage: aptitude [-S fname] [-u|-i]
Actions (if none is specified, aptitude will enter interactive mode):
install - Install/upgrade packages
remove - Remove packages
purge - Remove packages and their configuration files
hold - Place packages on hold
unhold - Cancel a hold command for a package
markauto - Mark packages as having been automatically installed
unmarkauto - Mark packages as having been manually installed
forbid-version - Forbid aptitude from upgrading to a specific package version.
update - Download lists of new/upgradable packages
safe-upgrade - Perform a safe upgrade
full-upgrade - Perform an upgrade, possibly installing and removing packages
forget-new - Forget what packages are "new"
search - Search for a package by name and/or expression
show - Display detailed information about a package
clean - Erase downloaded package files
autoclean - Erase old downloaded package files
changelog - View a package's changelog
download - Download the .deb file for a package
reinstall - Download and (possibly) reinstall a currently installed package
why - Show the manually installed packages that require a package, or
why one or more packages would require the given package
why-not - Show the manually installed packages that lead to a conflict
with the given package, or why one or more packages would
lead to a conflict with the given package if installed
-h This help text
-s Simulate actions, but do not actually perform them.
-d Only download packages, do not install or remove anything.
-P Always prompt for confirmation or actions
-y Assume that the answer to simple yes/no questions is 'yes'
-F format Specify a format for displaying search results; see the manual
-O order Specify how search results should be sorted; see the manual
-w width Specify the display width for formatting search results
-f Aggressively try to fix broken packages.
-V Show which versions of packages are to be installed.
-D Show the dependencies of automatically changed packages.
-Z Show the change in installed size of each package.
-v Display extra information. (may be supplied multiple times)
-t [release] Set the release from which packages should be installed
-q In command-line mode, suppress the incremental progress
-o key=val Directly set the configuration option named 'key'
--with(out)-recommends Specify whether or not to treat recommends as
-S fname Read the aptitude extended status info from fname.
-u Download new package lists on startup.
-i Perform an install run on startup.
1.To search for a package with aptitude:
sudo aptitude search package_name
it should provide you with a list of all packages that where found.
2.To show a detailed information about a package:
sudo aptitude show package_name
3.To install a package with aptitude:
sudo aptitude install package_name
4.To remove a package with aptitude:
sudo aptitude remove package_name
5.To remove a package and their configuration files with aptitude:
sudo aptitude purge package_name
6.To update the list of repositories packages with aptitude:
sudo aptitude update
Resources: Ubuntu.com and psychocats.net.