Posts Tagged ‘aptitude’

Purge Removed Packages On Ubuntu/Debian

March 24th, 2010 No comments

When a package is uninstalled, its configuration files are left on the system, in case you’ll want to install it again. Purging a package gets rid of these configuration files. This not only frees disk space, but also helps maintain the system clean. It’s easy to forget to add –purge to each apt-get or aptitude remove command you run, but there’s an easy way to purge packages after you’ve removed them:

Here’s a trick you can use to purge packages that have already been removed with apt-get remove or aptitude remove.

Check results of the following command.

$ aptitude search '~c'

If you think listed packages are OK to be purged, execute the following command.

$ sudo aptitude purge '~c'

Another way to using dpkg:

 $ dpkg -l |awk '/^rc/ {print $2}' |xargs sudo dpkg --purge

You may want to do the similar in the interactive mode for fine grained control.
Start aptitude in interactive mode.

$ sudo aptitude

You provide the regex “~c” in the “New Package Tree Limit” view with “l” prompt.

This limits the package view only to regex matched packages, i.e., “removed but not purged”.


All these regex matched packages can be shown by pressing “[” at top level headings.

Then you press “_” at top level headings such as “Installed Packages”. Only regex matched packages under the heading are marked to be purged by this. You can exclude some packages to be purged by pressing “=” interactively for each of them.


Finally press “g” to perform all pending installations, removals, and upgrades.


This technique is quite handy and works for many other command keys.

Categories: DEBIAN/UBUNTU, HOW-TOS Tags:

Basic Package Management Operations Using Aptitude

March 24th, 2010 2 comments

debianaptitude is a featureful package manager for Debian GNU/Linux systems, based on the renowned apt package management infrastructure. aptitude provides the functionality of dselect and apt-get, as well as many additional features not found in either program.

For the package management operation which involves package installation or updates package metadata, you need to have root privilege.

Here are basic package management operations with commandline using aptitude(8).

Working With aptitude

Update package archive metadata.

aptitude update

Install candidate version of “foo” package with its dependencies.

aptitude install foo

Install candidate version of installed packages without removing any other packages.

aptitude upgrade

Install candidate version of installed packages while removing other packages if needed.

aptitude dist-upgrade

The difference between “safe-upgrade”/”upgrade” and “full-upgrade”/”dist-upgrade” only appears when new versions of packages stand in different dependency relationships from old versions of those packages. The “aptitude safe-upgrade” command does not install new packages nor remove installed packages.

Remove “foo” package while leaving its configuration files.

aptitude remove foo

Remove “foo” package and its configuration files.

aptitude purge foo

Clear out the local repository of retrieved package files completely.

aptitude clean

Clear out the local repository of retrieved package files for outdated packages.

aptitude autoclean

Display detailed information about “foo” package.

aptitude show foo

Search packages which match ‘regex’.

aptitude search <regex>

Explain the reason why ‘regex’ matching packages should be installed.

aptitude why <regex>

Explain the reason why ‘regex’ matching packages can not be installed.

aptitude why-not <regex>

Notable command options for aptitude

-s simulate the result of the command
-d download only but no install/upgrade
-D show brief explanations before the automatic installations and removals

List of the aptitude regex formula

~n match on package name
~d match on description
~t match on task name
~G match on debtag
~m match on maintainer
~s match on package section
~V match on package version
~A{sarge,etch,sid} match archive
~O{debian,…} match origin
~p{extra,important,optional,required,standard} match priority
~E match essential packages
~v match virtual packages
~N match new packages
~a{install,upgrade,downgrade,remove,purge,hold,keep} match with pending action
~i match installed packages
~M match installed packages with A-mark (auto installed package)
~i!~M match installed packages without A-mark (administrator selected package)
~U match installed and upgradable packages
~c match removed but not purged packages
~g match removed, purged or can-be-removed packages
~b match packages with broken relation
~B match packages with broken depends/predepends/conflict
~D[:] match packages from which relation is defined to package
~DB[:] match packages from which broken relation is defined to package
~R[:] match packages to which the package defines relation
~RB[:] match packages to which the package defines broken relation
~R~i match packages to which some other installed packages depend on
!~R~i match packages to which no other installed packages depend on
~R~i|~Rrecommends:~i match packages to which some other installed packages depend or recommend on
~S filter match package with filtered version
~T match all packages (true)
~F match no packages (false)