Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

For uninstalling an app (or package) should I use apt-get remove package-name or apt-get purge package-name?

What is advantage of any of them to other one?

share|improve this question
up vote 30 down vote accepted

If you have customized the package/software at all, either by editing the config files directly, or via a GUI, you may want to keep your customizations. Usually in Unix/Linux systems, configurations are saved in text files, even if the configuration/customization is done via the GUI.

Each Debian binary deb package has a list of files which it identifies as config files. dpkg, and thus apt honor this identification when removing packages, and also on upgrades. By default apt/dpkg will not remove config files on package removal. You have to request a purge. On upgrade it will ask you to choose between the current version and the new version (if they differ) before overwriting config files. Even in that case, it saves a copy of the original file. Here Debian is trying to help you, based on the assumption that your config files may contain valuable information.

So, if you have not configured the package, or you don't want to keep your configurations, you can use apt-get purge.

If you do keep the config files, then if/when you reinstall the package, Debian will attempt to reuse the saved configuration information. If the version of the package you are trying to (re)install has config files that conflict with the configuration files that are already installed, it will again ask you before overwriting, as it does on upgrade.

Minor comment: If you have removed the package and later want to remove the config files,it used to be the case that apt would no tremove the config files if the package was not installed. However, for some years now, running apt-get purge will remove config files even if the package is no longer installed.

This was fixed in the 0.8.0~pre1 version of apt, released on Fri, 13 Aug 2010, or possibly in the 0.8.15~exp1 version of apt, released Fri, 10 Jun 2011. See Debian Bug Report: apt-get --purge does not work as expected, dated 24th June 2002.

share|improve this answer
    
Are these equivalent: apt-get remove --purge APP VS apt-get purge APP? – mini Jul 26 '14 at 8:18
    
@mini: Yes. Quote from the apt-get man page, "remove --purge is equivalent to the purge command." – Faheem Mitha Jul 26 '14 at 8:39
    
if you have removed the package and later want to remove the config files, you will need to call dpkg directly, because apt will not remove the config files if the package is no longer installed. Does it mean that apt-get purge will not remove config files after apt-get remove has been executed? – Anmol Singh Jaggi Mar 6 at 13:32
    
@AnmolSinghJaggi This part is actually incorrect and out of date. I meant to change it before. I'm changing it now. – Faheem Mitha Mar 6 at 15:10
    
@FaheemMitha Okay! – Anmol Singh Jaggi Mar 6 at 15:14

From the man page of apt-get:

   remove
        remove is identical to install except that packages are removed 
        instead of installed. Note that removing a package leaves its 
        configuration files on the system. If a plus sign is appended to the 
        package name (with no intervening space), the identified package 
        will be installed instead of removed.

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

I would tend to use purge if you tend to not want to keep any configuration files around.

share|improve this answer

purge remove configuration files of your packages, but remove keep configuration files of your package.

But advantages or disadvantages: It's related to your system, your packages, your machine, install it or not, and so on.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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