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.
Kinda embarrassing answering to my own question but found a solution how to remove orphaned packages that satisfies my needs.
First I made a new custom filter in Synaptic package Manager.
Settings -> Filters
Than Deselected All and checked only Orphaned check box and saved.
Now synaptic is listing all orphaned files. Note that synaptic will list files with no dependencies as orphaned too so don't remove anything you're unsure what it is (and if it is really orphaned).
Than I installed GtkOrphan using CLI sudo apt-get install gtkorphan
which is a GUI for deborphan but adds option to remove packages too.
Once started GtkOrphan and has to be run as root, under Orphaned packages tab expand the Options and check the "Show all orphan packages, not only those in the libs section". After that GtkOrphan will report as "orphaned" all packages that have no dependencies too, for example libreoffice, ubuntu-desktop, ubuntu-restricted-extras, myunity
and etc. Now you can check the list and using right-click context menu chose to hibernate each package you don't want to be reported as orphaned. List of hibernated packages can be accessed from right click context menu or View menu.
Always under Orphaned packages tab and expanded Options check the "Show uninstalled packages with orphaned configuration files". Before removing anything make sure you know what are the files you want to delete. In my case GtkOrphan found some old nautilus configuration files not shown in Synaptic Package Manager.
In case you delete some of configuration files you need re-installing the package should solve the problem.
Best Answer
That is the proper way, there is no better way available.
Files created into your home dir, or other files created during normal package working, as i.e. log files, do not get removed, and there is no easy way to do so, if the preremove and postremove script do not do so themself. Obviously the problem is not in the removing, but in the individuation of such files.
The fact that the service you talk about keep on starting on boot is strange, it is perhaps present in another package? What
dpkg -l | grep nginx
returns?