4

sudo apt-get remove --purge wine* opened the gates of hell and removed many things. I wasn't allowed to paste the output here, too big. I stopped the process, I wanted to save what's left of my system!

  1. How to reinstall what has been removed?
  2. Why were these packages removed? It is the most important question, why the hell were they removed? I can't see any relation between Spotify and wine!
  3. If apt-get --purge might destroy your system, how to remove wine then? I removed it from software center but many files were still there.
  4. Can you ever trust apt-get -- purge?

I'm on Xubuntu 14.04 64 bit.

Lynob
  • 6,675
  • Hard to know if your problem was a typo or a bug. wine * is not the same as wine*. I suggest you now use wildcards with apt-get purge. Also, you should have gotten a warning before any critical packages were removed, I hope you did not ignore that. I suggest you run sudo apt-get install xubuntu-desktop – Panther Apr 11 '14 at 22:47
  • @bodhi.zazen well sudo apt-get install xubuntu-desktop but it says E: Could not get lock /var/cache/apt/archives/lock - open (11: Resource temporarily unavailable) E: Unable to lock directory /var/cache/apt/archives/ – Lynob Apr 11 '14 at 22:49
  • You have to close any other package managers running, including software center first. – Panther Apr 11 '14 at 22:50
  • 1
    Also, the --purgeflag doesn't destroy a system by itself; it just removes configuration files from the packages removed by the command. – saiarcot895 Apr 11 '14 at 22:51
  • @bodhi.zazen nothing is opened, but the terminal, no process is running in the background as far as I can tell – Lynob Apr 11 '14 at 22:51
  • See http://askubuntu.com/questions/15433/unable-to-lock-the-administration-directory-var-lib-dpkg-is-another-process – Panther Apr 11 '14 at 22:53
  • 6
    Based on Note, selecting 'libapache2-mod-auth-ntlm-winbind' for regex 'wine*', it saw that the package name contained "win" ("e" means 0 or more instances of "e") and removed it. Then, the dominoes fell... (This is also why a list of packages to be removed is displayed for review before* you enter yes.) – saiarcot895 Apr 11 '14 at 22:53
  • @saiarcot895 then how to remove wine? – Lynob Apr 11 '14 at 23:00
  • Since you have Wine 1.6, apt-get --purge remove wine-1.6. – saiarcot895 Apr 11 '14 at 23:01
  • @saiarcot895 I've never put the version of the software I'm removing before, that's good to know. Can I tell what software were removed to reinstall them? so far I noticed elements from xubuntu-desktop, I reinstalled that just to be sure, and spotify and virtualbox, the others are libraries, I don't know what software were damaged – Lynob Apr 11 '14 at 23:08
  • The easiest way to get back to a stable system would probably be to install xubuntu-desktop. After that, remove any NON-critical packages (applications) you don't need. – saiarcot895 Apr 11 '14 at 23:11
  • 1
    They were removed because you entered "Y" and hit enter! Always double check when you're doing something as root! – Jorge Castro Apr 11 '14 at 23:14
  • @JorgeCastro I know I pressed yes, it just showed some packages to be removed, i thought it was no big deal, I thought they belong to wine and winebricks because winebricks installs many packages on the system - it would be helpful if Ubuntu shows what software use the packages to be removed – Lynob Apr 11 '14 at 23:20
  • The fact that the apt- family of commands take a regexp instead of a globbing is so surprising that I almost would define it as a bug. Alas, I even hate the fact that bash (unlike zsh) defaults to pass the * when there is no match in the glob... This is at least the third time I see an user bitten by this problem. The correct apt-get remove --purge "wine.*" would have caused much less damage. – Rmano Apr 12 '14 at 04:37
  • 1
    See Why does apt removes unwanted packages when giving * as suffix?, How to fix Ubuntu after accidentally uninstalling many packages? I think we can mark this a duplicate of one of them. @Rmano Use ^wine to match wine just at the beginning. Btw, the failglob shell option may interest you. – Eliah Kagan Aug 23 '17 at 19:32

3 Answers3

2

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.

Eliah Kagan
  • 117,780
dfherr
  • 121
  • Using wine.* will match just package names that contain wine, but this still might be more than is needed. In particular, if it's sufficient to remove packages whose names start with wine then ^wine can be used (e.g., apt-get remove --purge ^wine). – Eliah Kagan Aug 25 '17 at 10:37
1

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.

mchid
  • 43,546
  • 8
  • 97
  • 150
-1

Aside from @mchid's correct answer, the command you should've used was

sudo apt-get remove wine\* 

Notice the backslash. It instructs the shell not to open the wildcard, and pass it to apt-get as is instead. What happened is that your shell interpreted the wine* and passed a whole lot of package names for apt-get to remove, instead of just the ones you expected.

philsf
  • 854
  • 3
    This is incorrect. The shell will only expand filenames based on globs, not package names based on regexes. As shown in the link in the question, you have output like Note, selecting 'kwin-style-skulpture' for regex 'wine*'. The shell doesn't produce output like that. This output comes from apt-get, which means the shell didn't expand anything because apt-get got the unexpanded glob with the * rather than a bunch of filenames. – Chai T. Rex Dec 13 '16 at 15:15
  • 2
    Don't do this! See Why does apt removes unwanted packages when giving * as suffix? The purge or remove action with an argument like wine*, wine\*, or 'wine*' removes way more than you might think. It removes every package with win anywhere in its name (not wine, win--as wine* is treated as a regex and e* means "zero or more es") and every package that depends directly or indirectly on any of those packages. This often breaks an Ubuntu system very badly, preventing it from being used for much of anything until it is fixed or reinstalled. – Eliah Kagan Aug 23 '17 at 19:17