7

When I remove a package in Ubuntu using apt-get remove package, it always seems to leave behind a lot of files... for example, log files in /var/log, config files in /etc, data in /var/lib, etc.

How do I COMPLETELY remove every trace of a package in Ubuntu, as if it never existed?

10

You should purge those packages.

apt-get purge somepackage

from man apt-get (APT-GET(8))

   purge
       purge is identical to remove except that packages are removed and purged (any configuration files are deleted too).

This is supposed to remove everything added by the package, such as config and data files. But I would assume it's possible that it generated something that is left behind anyway. dpkg doesn't track everything related to a package... and its cleanup scripts and such can be assumed to be imperfect and sometimes fail. Maybe it won't remove logs for example.

3
  • 2
    It should be noted that even purge does not remove e.g. config files in ~/.local, see this answer over on askubuntu for a deeper dive. – Jared Smith Feb 25 '19 at 14:10
  • 5
    purge will not remove files which were generated by the application, as opposed to the ones installed by apt. This includes the files generated indirectly, such as logs (which come from the app sending logging events to /dev/log, which is then parsed by another utility (rsyslog, ...) – WoJ Feb 25 '19 at 17:40
  • @WoJ This depends on the package: For example, if a package logs directly to /var/log/$package, it's totally possible that this gets removed, if purge is requested. That is in contrast to anything in $HOME (as noted above), which apt must not touch, according to policy. – gf_ Dec 5 '19 at 13:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.