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.
2 Answers
Procedure for dash:
sudo apt-get download dash #download dash *.deb file
sudo dpkg-deb -x dash*.deb #extract deb file, a bin directory will be created
sudo cp ./bin/dash /bin/ #copy binary file to /bin directory
sudo ln -s /bin/dash /bin/sh #create a symbolic link from sh to dash
Now dash binary is recovered and everything should be OK, but to just to make sure, run this:
sudo apt-get install --reinstall dash
Same procedure for bash, but this time there is no need to create a symbolic link:
sudo apt-get download bash
sudo dpk-deb -x bash*.deb
sudo cp ./bin/bash /bin/
Just to make sure:
sudo apt-get install --reinstall bash
As you currently have a working system:
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.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.