Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I accidentally removed libc6 and now every command returns "No such file or directory"

example: "bash: /bin/ls: No such file or directory"

Is there anything that can be done to reinstall libc6?

P.S. apt-get, dpkg return the same error

share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

It is possible to recover from a mistake like that without shutting the system down, but it tends to involve deep Unix voodoo. You would need to figure out which commands do still work (these will be the ones that were statically linked when they were compiled) and from those, figure out a way to get another identical copy of libc6 back on the system, in the right place and with the right permissions.

This might involve something like using cat to paste the file into an open session and redirect the output to a file. If you're lucky, some process might still have the file open meaning you could recover it from /proc.

Here's an old tale of someone who did just that.

By far the easiest method will be to shut the system down, physically move the hard drive(s) to another machine, copy an identical libc6 back into the right place, move the hard drive(s) back to the original machine and boot it back up.

share|improve this answer
add comment

I'm not very familiar with Ubuntu, but you should be able to boot from the installation media as rescue, and from there reinstall the glibc package. Go check their website (or Debian's) for more detailed instructions.

share|improve this answer
add comment

Your Answer

 
discard

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.