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.
4 Answers
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...
2There 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.
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] 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 purgeis a useful, later-added shorthand for the complete removal of specific packages- The
--purgeflag allows modification of other apt-get calls to purge configuration files as well, as inapt-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!