Broke most Linux computer functions with bad symlink

Posted on

Problem :

I’m using 64-bit Crunchbang, which is Debian-based.

I was trying to fix a certain problem with libc6, and naively followed the advice of an askUbuntu answer (link) that made me run the following command:

sudo ln -sf /lib32/libc.so.6 /lib/x86_64-linux-gnu/libc.so.6

Now I cannot run a single terminal command or GUI program. On terminal I get a plethora of errors. Here is ls, for example:

ls: error while loading shared libraries: libs.so.6: wrong ELF class: ELFCLASS32

sed: error while loading shared libraries: libs.so.6: wrong ELF class: ELFCLASS32

/usr/bin/env: error while loading shared libraries: libs.so.6: wrong ELF class: ELFCLASS32

date: error while loading shared libraries: libs.so.6: wrong ELF class: ELFCLASS32

sed: error while loading shared libraries: libs.so.6: wrong ELF class: ELFCLASS32

GUI programs simply don’t launch or give me strange errror messages.

In short, I have no way to delete the symlink that caused this catastrophe. What can I do to get my computer working again?

Solution :

The /lib32 folder can only contain 32 bit libraries. You created a link of libc.so.6 in /lib32 that points to the 64 bit version of the same file. Get a 32 bit version of libc.so.6 and place it in the /lib32 folder.

Since you’ve mucked up your libc and generally every useful utility depends on it, your only real convenient option is to boot off a Live CD / USB and fix it, or stick your hard drive in somebody else’s computer (don’t boot off it) and fix it from there.

To fix it, undo what you did.

However, your poor choice of the -f option to ln and presumed failure to back up any original file means that if /lib/x86_64-linux-gnu/libc.so.6 actually existed before you did that command, it was overwritten. In that case your best bet would be to obtain a copy from elsewhere, hopefully a compatible version, then do a forced reinstall of libc once you get your machine operational again just to make sure that all the right versions of the right files are in the right places.

If you didn’t have that file to begin with then no worries there.

After you clean this all up, consider attempting less risky solutions to whatever your problem was, such as unmasking and installing correct packages for your platform, etc., instead of mucking around with symlinks to critical libraries.

Leave a Reply

Your email address will not be published. Required fields are marked *