apt-get remove --purge wine* removed everything! [duplicate]

This particular problem bit me too. apt-get remove wine told me wine was not installed, while which wine and wine version were still functional. wine-devel and multiple other packages were installed though and you don't want to type them all one by one.

It's especially frustrating as you look at the list and actually see a lot of wine software getting removed as expected (as the list is displayed alphabetically they come close to last and take nearly the whole screen) and then hit Y.

Both answers provided here are wrong and it is not a misuse of the wildcard. It is beautifully explained in gertvdijk's answer to What is the correct way to completely remove an application?

The issue comes from apt-get interpreting the input as a regular expression and therefore interpreted the asterisk as "zero or more times" and not as the expected wildcard, resulting in removing any packages that contain the string win and any package that depends on such a package (which basically uninstalls nearly your whole system).

The command that would've done what I expected would've been

apt-get remove --purge 'wine.*'

That removes all packages whose names contain wine.


Uninstall did this, not purge. Don't feel bad, I think we've all done it at one point in time or another.

Run the command again, however, this time run the command

sudo apt-get purge wine

without the * mark and this time, submit "n" to not uninstall at this time. Now, before you execute the command again, you should take note of the list of programs that will be uninstalled along with wine so you may reinstall these programs after the purge and before the next reboot.

I like to make a copy of this list that can be pasted into a text editor. Once copied into the text editor, you can remove all the paragraphs and * marks to make a smooth list that can be copied and pasted after a sudo apt-get install command to run immediately after the purge is done. Luckily, programs like Spotify retain their configuration files during this process as they were not explicitly marked to purge, only to uninstall so when you re-install them they should be good as new.