OK, First the lecture:
DON'T MESS WITH SYSTEM BINARIES
Anything in /bin
, /sbin
and /rescue
on FreeBSD should be left alone. Even if you know what you're doing (if you know what you're doing you also know these should be left alone. They're really important -- all of them!)
DON'T delete /bin/sh
. EVER. On any *NIX system that has it.
Really. Don't do it. A LOT of scripts rely on /bin/sh
being a Bourne Shell. It breaks the universe.
If you REALLY want to you can probably safely replace it with a copy of bash
like Adam Z suggested, but if you're going to do that you may want to statically link that copy of bash
-- It pulls in a lot of libraries, and you may not have those until the system is up and /usr/local
is mounted.
Now, how to fix the mess? Two options:
Option 1: Somewhat painful
Head on over to http://www.freesbie.org/ (or the FreeBSD LiveCD of your choice - You can probably even use the recovery CD from http://www.freebsd.org for this). Grab the LiveCD, burn it, and boot it.
Once you're up in the LiveCD environment mount your busted system's root partition, copy the /bin/sh
from the LiveCD to your machine, then reboot.
This should get you back up and running -- You may want to follow the instructions for Rebuilding "World", or at least re-compile /bin/sh
from a source tree that matches your running system though.
Option 2: Less painful, no LiveCD
If you have another FreeBSD box around you can mooch off of (or some other way to get your fingers on a copy of /bin/sh
, bring your FreeBSD machine up in single user mode. Configure the network (or mount whatever media has the replacement shell on it), and copy it into place where it's supposed to be.
Reboot and you should be OK -- same caveats as the LiveCD though if the /bin/sh
you grab it isn't from a reasonably-close-to-identical machine.