Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

What is the difference between sudo apt-get purge and sudo apt get remove --purge?

There must be a difference or both of them shouldn't exist.

share|improve this question

4 Answers 4

up vote 12 down vote accepted

Whether they should or shouldn't both exist is perhaps a debating point.

However - they are absolutely identical.

From the man page of apt-get

--purge
           Use purge instead of remove for anything that would be removed. An
           asterisk ("*") will be displayed next to packages which are
           scheduled to be purged.  remove --purge is equivalent to the purge
           command. Configuration Item: APT::Get::Purge.

They key part is --purge is equivalent to the purge command

As to why - I would surmise this is historical -

apt-get --purge remove came before apt-get purge

Looking at the old apt documentation it make reference to the older version of the command. The newer documentation gives the aptitude & apt-get purge example.

For the sake of consistency - its a good idea to not remove old interfaces - if you have an old script - it will still work today because the interface commands still exist.

Mind you that doesnt stop Gnome from deprecating api's - but that's another story...

share|improve this answer
    
If I might add, the --purge switch comes in handy when you use the autoremove command. There is no other way that I know to make apt-get delete configuration files of packages that are being automatically removed. –  Igor Zinov'yev Sep 5 '12 at 5:45
    
There is a nice thing about having both in that you can combine --purge with apt-get autoremove. –  Ian Santopietro Oct 16 '13 at 16:37

There isn't one as far as I know, they do the same thing exactly, remove packages and try to remove any configuration files created by those packages.

Basically apt-get purge was implemented after apt-get remove --purge but the old option styled purge still remained.

share|improve this answer

They are the same, as it says in the official man page: remove --purge is equivalent to the purge command. See man apt and the Ubuntu manpages online. I think the usage developed and both commands remained; as happens in other programs, usage changes and one form (i.e. sudo apt-get purge) becomes preferred over the other. However, I am still looking for a reference for this and researching the history of the usage, although there are useful chapters on package management in the Debian Handbook and articles on apt-get at Raphael Hertzog's blog.

Using the example of removing vlc (albeit with the -s simulate flag), we can see that the commands have identical results; all the other files used by vlc need to be removed with sudo apt-get autoremove in both cases.

1) sudo apt-get remove --purge

sudo apt-get -s remove --purge vlc
[sudo] password for mike: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libdc1394-22 libxcb-keysyms1 libzvbi0 libxcb-xv0 libtar0 libass4 libdvbpsi7
  libvlc5 vlc-nox libupnp3 libzvbi-common libxcb-randr0 libxcb-composite0
  libiso9660-8 libkate1 vlc-plugin-notify vlc-plugin-pulse vlc-data
  libdirac-encoder0 libvlccore5 libvcdinfo0 libebml3 libmatroska5
  libsdl-image1.2
Use 'apt-get autoremove' to remove them.
The following packages will be REMOVED
  vlc*
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
Purg vlc [2.0.3-0ubuntu0.12.04.1]

2) sudo apt-get purge

sudo apt-get -s purge vlc
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libdc1394-22 libxcb-keysyms1 libzvbi0 libxcb-xv0 libtar0 libass4 libdvbpsi7
  libvlc5 vlc-nox libupnp3 libzvbi-common libxcb-randr0 libxcb-composite0
  libiso9660-8 libkate1 vlc-plugin-notify vlc-plugin-pulse vlc-data
  libdirac-encoder0 libvlccore5 libvcdinfo0 libebml3 libmatroska5
  libsdl-image1.2
Use 'apt-get autoremove' to remove them.
The following packages will be REMOVED
  vlc*
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
Purg vlc [2.0.3-0ubuntu0.12.04.1]
share|improve this answer

As previous answers have stated, the two are indeed equivalent.

One valid reason does come to mind for the continued existence of both forms, however:

  • apt-get purge is a useful, later-added shorthand for the complete removal of specific packages
  • The --purge flag allows modification of other apt-get calls to purge configuration files as well, as in apt-get autoremove --purge

As a regular experimenter with new software, I myself have had considerably less old configuration files floating around since learning how to modify autoremove calls!

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.