0

The error might be a bit different than the one from the topic- I was translating it from my native language.

After everything failed, I tried doing as mjp pointed in this post: GLIBCXX_3.4.20 not found, how to fix this error?

But as a result every command- apt-get, mv, cp returns the error from the topic title. I cannot go back to the backup version of the file.

At the moment I can't even log into Ubuntu. I got lopped inside the login screen. Everytime I try to login, screen gets black and I get back to login. I can only use the comand via ctrl+alt+F3

What should I do?

Answer for steeldriver (please look at the comment):

lrwxrwxrwx 1 root root 40 Jun 17 21:37 /usr/lib/x86_64-linux-gnu/libstdc++.so.6 -> /usr/lib/x86_64-linux-gnu/libstdc++.so.6

-rw-r--r-- 1 root root 979056 May 7 2016 /usr/lib/x86_64-linux-gnu/libstdc++.so.6.19

lrwxrwrwx 1 root root 19 May 7 2016 /usr/lib/x86_64-linux-gnu/libstdc++.so.6.old -> libstdc++.so.6.0.19
Charles Green
  • 21,339
  • What exactly did you do? (if you ran an ln command, what libraries did you link from and to?). You may be able to fix it by booting into the recovery root shell, remounting the filesystem in read-write mode, then using the statically-linked busybox ln to revert your snafu. In the meantime try /bin/busybox ls -l /usr/lib/$(uname -m)-linux-gnu/libstdc++* and add the result to your question – steeldriver Jun 17 '17 at 20:53
  • I cant' really paste because I'm working on alt+ctr+f3 shell, I'll re-write it in new post – Kokos34 Jun 17 '17 at 21:24
  • @steeldriver The OP added the output of your command as an answer to their question - I placed it into the original question. It looks like the op was in the wrong directory when they created a link to the library. – Charles Green Jun 17 '17 at 22:53
  • Is it possible to somehow revert it? – Kokos34 Jun 18 '17 at 13:17

1 Answers1

1

[I must admit I'm a bit puzzled why basic utilities like mv or cp would break because of libstdc++.so.6, however asssuming that's the reason, here's what I would try]

Your busybox ls output indicates that you have managed to recursively link /usr/lib/x86_64-linux-gnu/libstdc++.so.6 to itself. Thankfully, it appears that you have not deleted or overwritten the actual /usr/lib/x86_64-linux-gnu/libstdc++.so.6.19 library. So you should be able to recover by re-creating the symbolic link.

The gotcha will be if either sudo or ln or both rely on the libstdc++ library. (Presumably bash doesn't, since you are able to login with a shell at the Ctrl+Alt+F3 virtual terminal.)

If sudo is broken, then you should still be able to boot into a root shell from recovery mode, as described in How do I boot into a root shell?. You will then need to remount the root filesystem in read-write mode

mount -o remount,rw /

After that, you can attempt to fix the broken link

ln -sf libstdc++.so.6.19 /usr/lib/x86_64-linux-gnu/libstdc++.so.6

(this should create a relative symlink that is resolved relative to the target path /usr/lib/x86_64-linux-gnu/, similar to your .old link).

Assuming that fails because ln depends on libstdc++.so, you can try again using the statically-linked busybox executable, which has a built-in ln:

/bin/busybox ln -sf libstdc++.so.6.19 /usr/lib/x86_64-linux-gnu/libstdc++.so.6

If that works, you can exit the root shell to proceed with the normal boot.

steeldriver
  • 136,215
  • 21
  • 243
  • 336
  • But the sudo command works fine. Sudo does not seem to rely on libstdc++. Should I still boot into root shell? – Kokos34 Jun 18 '17 at 14:50
  • ln -sf libstdc++.so.6.19 /usr/lib/x86_64-linux-gnu/libstdc++.so.6

    results in the same error.

    /bin/busybox ln -sf libstdc++.so.6.19 /usr/lib/x86_64-linux-gnu/libstdc++.so.6

    says: ln: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: File exists

    – Kokos34 Jun 18 '17 at 14:57
  • @Kokos34 hmm... you definitely did ln -sf not just ln -s? will need to think about that – steeldriver Jun 18 '17 at 16:51
  • Yes, I'm sure. Checked again. Maybe I should firstly delete the file? -f flag means "force" or "folder"? – Kokos34 Jun 18 '17 at 18:50
  • Yes -f means force - by all means try deleting first (with busybox rm if necessary) - just make sure to delete the broken link (/usr/lib/x86_64-linux-gnu/libstdc++.so.6) not the real file (/usr/lib/x86_64-linux-gnu/libstdc++.so.6.19). Alternatively, once you've deleted the broken link you could just use busybox mv to rename the /usr/lib/x86_64-linux-gnu/libstdc++.so.6.old link back to /usr/lib/x86_64-linux-gnu/libstdc++.so.6 – steeldriver Jun 18 '17 at 19:19
  • Thank you very much. After I've renamed the file to libstdc++ they problem was solved – Kokos34 Jun 18 '17 at 20:16