How to remove a package entirely?
Solution 1:
apt-get autoclean
will just remove old versions from the package archive, but won't change anything for installed packages.
To remove a package use sudo apt-get purge package
. This should uninstall any dependencies, but won't full remove them. I use the command aptitude purge ~c
to `.clean all uninstalled packages.
Even purged packages may leave behind data files and backup files. Backups should be a directory under in /var/backup
. Data files will likely be in /var/lib
. I would backup the data files before removing them in case some other application uses them. You may want to grep the data file directory in /var/lib/dpkg/info
. If any files use the directory, then keep it. For example to find which packages installed use /var/lib/ldap
, I run the search grep -l /var/lib/ldap /var/lib/info/dpkg/*
. If you have a lots off packages you may need to use find /var/lib/dpkg/info | xargs grep -l /var/lib/ldap
.
EDIT: You can list all programs which could be marked as automatically installed with the command aptitude search '~i!~M?for x: ~D( ~i!~M )'
. Pipe this to the commands 'cut -d\ -f4 | sudo aptitude markauto` to mark these packages as auto-installed.
I then use the command aptitude search '~i!~M'
(installed, not automatically installed) to list all the first order installed packages. WARNING: When removing packages, you may uninstall packages you want to keep. Simulate the removal first, and unmarkauto any packages you want to keep before run the real removal.
EDIT2: Above instructions includes packages suggested by other packages as first level packages. To list these use the command aptitude search '~i!~M?for x: ~Rsuggests:( ~i!~M )'
. If desired, these can be marked using the same pipeline as for other dependencies. However, you must configure suggested packages to be automatically installed, or all the suggested packages and their depencies will be automatically uninstalled. This is done by adding the line APT::Install-Suggests "true";
to /etc/apt/apt.conf
or a file in /etc/apt/apt.conf.d
.
Dependencies may lead to unexpected selections for first level packages. If neither wordpress
is marked wordpress-l10n
then wordpress-l10n
is considered the first level install. Normally wordpress-l10n
would be marked as automatically installed, so this would not be a problem. You will likely get a lot of cruft this way.