Remove all data and settings of an uninstalled application

35,101

Solution 1

You can use apt-get purge for the same exact purpose, here is an example:

  1. First remove your desired program using apt remove, then run:

    dpkg -l package-name
    

    You should get:

    ||/ Name              Version       Architecture  Description
    +++-=================-=============-=============-====================
    rc  package-name      1.1            amd64        something
    

    RC means:

    • r package has been removed.
    • c configuration files still lives on your system
  2. Now use apt-get purge for exact same program, this time dpkg -l package-name output should be like:

    ||/ Name              Version       Architecture  Description
    +++-=================-=============-=============-====================
    un  package-name      <none>        <none>        (no description available)
    

Solution 2

The location of the configuration files of an application varies from application to application, and sometimes it is time-consuming to find them. Even if an application has been removed, you can run sudo apt purge <package_name> to purge its configuration files.

Solution 3

The commands to remove/purge the packages have already been provided in other answers.

There are some discrepancies that can call some confusion, and leave some of the application's folders. If there are foreign files or directories in the applications configuration folders, it may not delete the folder, just the configuration files that it uses.

So the actual configuration files/settings will be removed.

The process should be followed the autoremove command.

This example will perform the task:

In the steps, I install a sample package that will include lots of configuration files. Then the commands that follow will remove the application and all its configuration files including the /etc/apache2 directory.

If you install libapache2-mod-php after installing apache2, the folders with the Php files will remain with the PHP configuration. If you don't install something that uses the shared folder, the folder will also be removed.

$ sudo apt install apache2
$ sudo apt purge apache2
$ sudo apt --purge autoremove

Note:
You can pick a different package to test the understanding of what happens with the install folders. The behavior will be the same for the actual application that you want to remove along with its configuration files and settings.

Solution 4

This is really simple and straight forward. I do it all the time. Just make sure to change the program name to the one you want to remove.

sudo apt-get --purge remove firefox

Then you want to remove all dependencies that were installed with your program; you no longer need them.

When removing has finished, continue:

sudo apt-get autoremove

Now everything to do with that program, is completely removed and uninstalled. No traces. If you installed a repository/ies, you can remove it/them by going to:

System Settings >> Software & Updates >> Other Software

On this page, you can click one-by-one, all the repositories you aren't using and click the "Remove" button beneath the box.

I hope this helps. This is what I do and it works as it should.

EDIT: if you want to do the first two steps in one line:

sudo apt-get --purge remove firefox && sudo apt-get autoremove
Share:
35,101

Related videos on Youtube

swa_mi
Author by

swa_mi

Updated on September 18, 2022

Comments

  • swa_mi
    swa_mi almost 2 years

    Given that I removed an application using apt remove, how do I remove the configuration files later, so that I get the result of apt purge?

  • ravery
    ravery almost 7 years
    sudo apt-get purge may work without reinstalling
  • George Udosen
    George Udosen almost 7 years
    Gosh you rock, I am digging your linux skill!
  • George Udosen
    George Udosen almost 7 years
    I have definitely learnt something today :)
  • Eliah Kagan
    Eliah Kagan almost 7 years
    Or sudo apt --purge autoremove to delete the dependencies' conffiles too.
  • Apologician
    Apologician almost 7 years
    You're so right. I'll improve the answer with your suggestion.
  • Soren A
    Soren A almost 7 years
    Or sudo apt --purge autoremove to also remove eventual configuration data for the packages you autoremove.
  • Captain Fudge
    Captain Fudge almost 7 years
    So, there's need to do -- purge remove then do apt autoremove? --purge autoremove will do both?
  • Soren A
    Soren A almost 7 years
    sudo apt remove --purge package removes package, then sudo apt autoremove --purge removes packages that has been installed automatically as dependencies, but unreferenced now. autoremove alone wont do anything.