Where to download missing libc.so.6

I recently accidentally deleted the file /lib/x86_64-linux-gnu/libc.so.6. This file is needed by most programs, so my computer is basically broken and I can only access the hard drive through a live USB.

I'm running 64-bit Crunchbang Waldorf, which is Debian-based.

How can I replace libc.so.6? (/lib64/ does not contain a copy.)

Output of locate libc.so (on live USB, with broken hard drive mounted)

/lib/x86_64-linux-gnu/libc.so.6
/rofs/lib/x86_64-linux-gnu/libc.so.6
/rofs/usr/lib/x86_64-linux-gnu/libc.so.6
/usr/lib/x86_64-linux-gnu/libc.so.6

Content of /etc/apt/sources.list

deb http://mozilla.debian.net/ wheezy-backports iceweasel-release

## CRUNCHBANG
## Compatible with Debian Wheezy, but use at your own risk.
deb http://packages.crunchbang.org/waldorf waldorf main contrib
# deb-src http://packages.crunchbang.org/waldorf waldorf main

## DEBIAN
deb http://http.debian.net/debian wheezy main contrib non-free
# deb-src http://http.debian.org/debian wheezy main contrib non-free

## DEBIAN SECURITY
deb http://security.debian.org/ wheezy/updates main contrib
# deb-src http://security.debian.org/ wheezy/updates main

Solution 1:

I am going to assume your live USB stick has the same distribution as you're running otherwise or at least it is a Debian based one.

With those assumptions first boot your system with your live USB stick. Then query which package owns the file /lib/x86_64-linux-gnu/libc.so.6 with command dpkg -S /lib/x86_64-linux-gnu/libc.so.6 (the file will turn out to be owned by the package called "libc6" but it is a nice exercise anyway).

When you have your system running from a USB stick live distro, download required package or packages from Crunchbang Waldorf site.

Then mount your hard disk drive to some directory. For the sake of example I'm going to, again, assume that you'll be mounting your root partition from your hard disk drive under /mnt.

Then all there is left to do is to re-install the required package or packages using --root /mnt directive for dpkg. That way the packages are not going to end up onto your live USB stick filesystem but instead into the system you already have on your hard disk.

Solution 2:

The libc.so.6 file is present in the libc6 package.

You have to find out from what repository the libc6 package was installed on your machine. (Check /etc/apt/sources.list, etc).

Then manually download it (For instance, if it was a Debian machine using the default repositories you could download it from here), and then install it using the instructions provided by @SamiLaine.

Solution 3:

Try this in a root shell :

ln -s /lib/x86_64-linux-gnu/libc-2.13.so /lib64/libc.so.6

If libc-2.13.so is not the right version for your system, use tab-completion in bash to find the right one.

If this doesn't work, you could follow with the statically-linked version of ldconfig in a root shell :

/sbin/ldconfig

If the target library for the libc links was deleted, download the debian package from the Package: libc6 page, unpack it using dpkg-deb -X (man page) and copy libc-2.13.so to /lib/x86_64-linux-gnu. Then run ldconfig to ensure that all links are correct.

Solution 4:

Open a terminal (Ctrl+Alt+T) and run the following commands:

For 64-bit Ubuntu:

sudo ln -s /lib64/x86_64-linux-gnu/libc.so.6 /lib64/libc.so.6

For 32-bit Ubuntu:

sudo ln -s /lib/i386-linux-gnu/libc.so.6 /lib/libc.so.6