Ubuntu – /bin/sh, /bin/bash and /bin/dash all broken, how can I install them again

bashdash-shelldpkg

Removed all /bin/sh, /bin/bash and /bin/dash. I cannot install them because dpkg and apt-get need a shell to install and there is no shell available. I'm still logged in and my Ubuntu is still running. Is there a way to recover from this situation. By the way, I don't have a Live CD right now.

Best Answer

As you currently have a working system:

  1. Download the packages. Normally I'd suggest running apt-get download bash dash but if you have a browser, you can fish them manually from http://packages.ubuntu.com/ Just make sure you get the version for your distribution release and architecture.

  2. Extract the files you need and put them in the right place. You might need to Alt+F2 to run pkexec nautilus to get root access to write.

    /bin/sh is actually a symlink to /bin/dash. I'm not sure how this is managed (it's a "diversion", but I'm not sure by which package) so you might need to manually create the symlink. Again from Alt+F2:

    pkexec ln -s /bin/dash /bin/sh
    

But I'd also download a LiveCD now while you're at it and get that burnt onto a USB stick. If you've forgotten anything you're going to need that when you reboot.

Related Question