Debian aptitude

Debian offers you tree servings of package management:
 * aptitude (high level)
 * apt-get and apt-cache (middle layer)
 * dpkg (low layer)


 * dpkg: handles simply installing and removing of packages
 * apt-get: keeps track of dependencies, and (since Debian 6) of manually or automatic installed packages
 * aptitude: a high level interface to apt-get.

Manually installed items
A list of packages manually selected with aptitude: aptitude search "~i\!~M" aptitude search '?installed ?not(?automatic)' # longer, but more readable A list of packages installed due to a dependency: aptitude search "~i~M"

For more search pattern, see the aptitute reference guide

Find unused packages
apt-get (and aptitude) can automatically remove packages with no reverse dependencies, but only if they are marked as "automatically installed".

To mark a package as "manually installed", either: aptitude unmarkauto package apt-get unmarkauto package To mark a package as "automatically installed" (due to dependency), either: aptitude markauto package apt-get markauto package

To remove packages that are marked as "automatically installed", but are not required by other packages: apt-get autoremove

A list of packages that are no dependency of others (no reverse dependencies): deborphan

A list of installed configuration files, without the program: dpkg -l | grep "rc "

Search for a package
List installed package by reg exp:

dpkg -l apache2* apt-cache search apache2* aptitude search "apache2*"

List of Files
From the APT FAQ (version 2 of the FAQ).

List of files in a package: apt-file list packagename

Find with package a file belongs to: apt-file search filename

Note that, like apt, you need to keep apt-file up-to-date: apt-file update

Dependencies
To display the dependencies of a package (whatever is needed by the package):

apt-cache depends packagename

To display which other package depends on a given package (the reverse dependencies):

apt-cache rdepends packagename

For even more detail (including version numbers for the dependencies), try one of these:

aptitude show packagename apt-cache showpkg packagename

See Dependency Graph Debian Packages to see how to visualize dependencies.

Updates
Of course, you must keep your system up-to-date with the latest security updates:

sudo apt-get update sudo aptitude upgrade