Debian offers you tree servings of package management:
- aptitude (high level)
- apt-get and apt-cache (middle layer)
- dpkg (low layer)
- handles simply installing and removing of packages
- keeps track of dependencies, and (since Debian 6) of manually or automatic installed packages
- 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:
A list of packages that are no dependency of others (no reverse dependencies):
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
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:
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.
Of course, you must keep your system up-to-date with the latest security updates:
sudo apt-get update sudo aptitude upgrade