Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

While I was installing MRTG, by mistake I have deleted /usr/lib/*.so.* and /usr/lib/*.so

I am now unable to boot-up my system now, it gets stuck at the splash screen and when I press PAGEDOWN button I can see there are several things which are failing to load.

However, DHCP and WebMin are running and from Webmin I can see the system logs which tells me that cups is not loading because libpipeline.so.1Is missing and several others.

My computer is running 11.04

share|improve this question

migrated from stackoverflow.com Jun 8 '11 at 10:21

This question came from our site for professional and enthusiast programmers.

1  
Cross posted on Unix and Linux –  Marco Ceppi Jun 8 '11 at 12:20
    
use Ask Ubuntu for Ubuntu specific questions. and don't cross post. If you aren't sure if it's ubuntu specific ask here first, and we will migrate if it's ubuntu specific. –  xenoterracide Jun 8 '11 at 12:44
2  
also a tip for the future... if you knew you did something this bad before you rebooted.... don't reboot. leave the system running and start repairs immediately. I've recovered /bin and /etc that way in the past –  xenoterracide Jun 8 '11 at 12:54

5 Answers 5

up vote 4 down vote accepted

Since you've only deleted /usr/lib/* and not /lib/*, you can probably recover. I think all the programs you critically need to recover your system only use libraries from /usr/lib.

Boot to a text login prompt. If the normal boot doesn't give you a login: prompt in text mode, boot with only minimum services. Press and hold Shift when your computer starts to show the Grub prompt; you need to press the key after the BIOS has initialized the keyboard but before Grub is loaded, which on some machines leaves only a small time window and may require several attemps. At the Grub prompt, press Down to highlight the single-user mode boot entry and boot that.

Once you have a command line, run apt-get --reinstall install PACKAGE1 PACKAGE2 … to reinstall the packages that have files in /usr/lib. You can run this shell snippet to get the list of names of packages to reinstall:

egrep -l '/usr/lib/[^/]*\.so\.' /var/lib/dpkg/info/a*.list |
sed -e 's!^/var/lib/dpkg/info/!!' -e 's!\.list$!!'

Some package installation scripts may require libraries from other packages to be present, so you may need to run the reinstallations in a particular order. If you find that a package's installation scripts are trying to use a particular program, you can find out which libraries this program needs with ldd. For example, this indicates that python is missing three libraries that you need to reinstall:

$ ldd /usr/bin/python | grep 'not found'
    libssl.so.0.9.8 => not found
    libcrypto.so.0.9.8 => not found
    libz.so.1 => not found

dpkg -S /usr/lib/libz.so.1 reveals that this file comes from zlib1g, and so on.

If you find that apt-get is unable to download packages, first download a few key packages from a live CD. zlib1g and libssl0.9.8 are two packages you're very likely to need early on.

share|improve this answer

You can spend a week finding everything that's missing or you can spend an hour just doing a reinstall from CD and then getting all your old packages back.

I'd suggest you boot into a LiveCD environment first to get backups of things first (copy them to an external USB drive, or another partition) and then start again.

share|improve this answer
2  
Exactly, if you don't reinstall everything you can expect weird failures, crashes, etc. to pop up for months after. –  JanC Jun 8 '11 at 22:38

/usr/lib contained the shared libraries of, frankly, everything except startup-critical software (that's what goes into /lib/ and stuff you didn't install via the package manager (usually /usr/local/lib ).

Short version, you just hosed your system.

Now, if you still have /var/cache/apt/archives full of stuff, with a little judicious magickery you might be able to salvage the situation.

Check if it still contains archives of for the following packages:

libxapian
libsigc++
apt
libcwidget
libsqlite
libboost-iostreams 

Those packages contain libraries in /usr/lib that aptitude requires to work If you can find the packages in /var/cache/apt/archives you can reinstall them manually with dpkg -i <packagename, and once they're all installed, aptitude should be able to run.

Then by running the command aptitude reinstall ~i you'll force a reinstall of every package that was already installed, which hopefully should restore your system. I can't make absolute guarantees because the damage you did is really quite spectacular in this case...

share|improve this answer

I'd be tempted to boot from a Ubuntu 11.04 live-CD and attempt to copy the missing files back.

Before doing anything, check you have good backups of any user-generated data files. If not, I'd boot a live-CD mount the HDD read-only and make backups ASAP.

share|improve this answer

When I did something similar, I was lucky enough to realise before attempting a reboot. At this point, your system will be still mostly working. My approach was to create a virtualbox with the same version of the OS and copy the missing files from that. if you allow ssh access into your virtualbox guest you can use rsync from a terminal on your main system to suck in only the files and links that are missing. In my case there were few enough files missing that it was easiest/safest to copy manually using scp, so the following is untested(!)

sudo rsync -avu user@guestVB:/usr/lib /usr/lib

-a is archive mode (recursive, copies symlinks, and attributes including timestamps, permissions etc)

-u skips if destination copy is newer

-v is verbose

share|improve this answer

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.