280

Is there any difference between

sudo apt-get purge <package-name>

and

sudo apt-get remove <package-name>  

?

I often see people recommend one or the other.

In other words, what does apt-get purge remove that apt-get remove doesn't?

essential
  • 107
Seth
  • 58,122
  • Related (since apt is similar, but an alternative to, apt-get): https://askubuntu.com/questions/936810/apt-remove-vs-purge – michael Sep 19 '18 at 19:21
  • 1
    @JürgenA.Erhard perhaps "how can I be a decent, considerate and polite human being?" should be your first question. We expect users here to be civil to each other and your comment is way out of line. Maybe take a walk next time you are frustrated instead of taking your frustration out on innocent posters of 9-year-old questions. If you can't say something constructive, please say nothing at all. That sort of comment is not welcome here. – terdon Dec 26 '21 at 19:29
  • How was my comment "uncivil". And "learn to read the docs first and then (docs can often be ) ask question" is the foundational constructive answer. – Jürgen A. Erhard Dec 26 '21 at 21:15
  • 3
    @JürgenA.Erhard "RTFM" is uncivil by definition, you know what the F stands for. Next, coming to a question that was asked 9 years ago and leaving a comment basically saying "go read the manual, you idiot" is useless beyond belief. It's been 9 years! An answer might still be useful, but a condescending, rude and uninformative comment, not so much. Finally, to add insult to injury, this particular OP has spent the intervening 9 years being very active on this site and learning a lot about Linux. They were even a mod for several years! It's safe to assume that they have read the manual by now. – terdon Dec 26 '21 at 22:29

3 Answers3

279

As the man apt-get page says:

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).

This of course, does not apply to packages that hold configuration files inside the user's home folder (e.g. /home/Ubuntu_User), these files will not be touched ( Why does "Purge" not remove everything related to an app? )

So for example, if you were to purge Chrome, Firefox, Kodi, or any other that holds some configuration files inside your /home folder, these configuration files will stay there.

On the other hand, if you were to install Apache, squid, MySQL, or any other services similar that save their configuration files in /etc, these configuration files will be deleted if you use purge.

Rishon_JR
  • 1,013
Luis Alvarado
  • 211,503
  • Purge can be used on a meta package to remove it, while leaving the underlying package intact. If you want to upgrade the base system without affecting postgres, you can apt-get purge the postgres meta package and then upgrading from Debian 7- Debian 8 will leave your postgres version untouched. – boatcoder Jul 07 '16 at 14:33
45

An excerpt from my answer on another question:

  • apt-get remove packagename
    will remove the binaries, but not the configuration or data files of the package packagename.
  • apt-get purge packagename, or
    apt-get remove --purge packagename
    will remove about everything regarding the package packagename, [...]
    Particularly useful when you want to 'start all over' with an application because you messed up the configuration.
gertvdijk
  • 67,947
27

apt-get purge removes configuration files, while apt-get remove does not.

d a i s y
  • 5,511
moon.musick
  • 1,892