I have followed a guide online which requested me to run this command:

sudo cp /opt/local/bin/node /bin/sh

It was a guide for fixing LESS. Instead of fixing it, it only made it worse. I have lost the file.

Is there any way to recover/refetch this file, or could someone upload their sh file for me?

  • 2
    To request someone to upload their sh for you is as risky as it was to follow the receipe you did. This is trust at random :).
    – dan
    Commented Aug 26, 2014 at 11:21

2 Answers 2


Run this command to copy /bin/sh from the BaseSystem.dmg on the Recovery HD:

diskutil mount Recovery\ HD &&
    hdiutil mount /Volumes/Recovery\ HD/com.apple.recovery.boot/BaseSystem.dmg &&
    sudo cp -p /Volumes/OS\ X\ Base\ System/bin/sh /bin/sh

Also see How can I get back a system file after deleting it from my Mac?


/bin/sh is actually a lot easier to fix if you have read through something like Linux from Scratch as it is usually a symlink on other UNIXes, pointing to a shell, usually /bin/bash, and occasionally /bin/dash.

The quick and fix:

sudo ln -sf bash /bin/sh

as it will create a symlink pointing from /bin/sh to /bin/bash just like every other UNIX and Linux distribution. You can of course symlink it to any other Bourne-compatible shells you would like to use, including that latest bash-4.3 or even Debian's dash.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .