Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In a misguided attempt to recompile ld with debug symbols, I ended up with a /lib64 that was not symlinked to /lib (Debian 64-bit libs are in in /lib/x84_64-linux-gnu). I attempted to reinstall libc6 using apt, which errored out complaining about the above.

I (mistakenly) figured I could just mv /lib64 /tmp && ln -s /lib /lib64; the first command worked, leaving a broken system (/bin/ld not found etc.).

Is there any way to fix this in-place? (i.e. without running a rescue disk)

If I could have posted this anonymously, I would have ... [sigh]

share|improve this question
Probably not, I suspect a boot off restore media is in order, unless you happen to have a big build of busybox hanging around somewhere? – Zoredache Jan 29 '12 at 21:26
up vote 2 down vote accepted

Not sure if this would have helped with part of it, but if you ever find you've moved the runtime linker so that things like mv,cp,ln,rm no longer work, you can still run them (and hopefully rescue yourself) by specifying the runtime linker explicitly. E.g.

    mv /lib64 /tmp
    ln -s /lib /lib64   # fails, no runtime linker
    /tmp/lib64/ /bin/ln -s /lib /lib64    # should succeed
share|improve this answer

If anyone else ever has this problem; once I had used a recovery disc to put the files back where they belonged, the following script allowed me to reinstall libc:


# Fix symlinks in a b0rked /lib64 (Debian).
# Libs in /lib64 should be symlinked to /lib/x86_64-linux-gnu;
# if a symlink is found in /lib64, try to redirect it to a
# file of the same name in /lib/x86_64-linux-gnu.
# Then remove the old symlink destination.
# The Problem:
# me@box # ls -l /lib64
# -rwxr-xr-x 1 root root  156683 2011-12-29 19:11
# lrwxrwxrwx 1 root root      10 2011-12-29 19:11 ->
# The Solution:
# lrwxrwxrwx 1 root root      10 2011-12-29 19:11 -> /lib/x86_64-linux-gnu/

set -e


for l in ${libs[@]}; do
    src=$(ls -l $l |awk '{print $10}');
    if [[ ! -z "$src" ]]; then
        if [[ ! -f "/lib64/$src" ]] || [[ ! -f "/lib/x86_64-linux-gnu/$src" ]]; then
            echo "error: $l src or dest not found:"
            echo `ls -l "/lib64/$src"` > /dev/null
            echo `ls -l "/lib/x86_64-linux-gnu/$src"` > /dev/null
        ln -si "/lib/x86_64-linux-gnu/$src" "$l";
        mv "/lib64/$src" $bak/;
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.