4

I have corrupted my /bin/sh and have no idea how to replace it. I accidentally copied over it. How can I fix this?

I am running Ubuntu Server 11.10, no X.

update: I have tried the fix that was kindly offered by Eliah but i think i copied over /bin/dash too!

update: OUTPUT OF cd /bin; file sh dash bash; md5sum sh dash bash

sh:   symbolic link to `dash'
dash: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=0x5d23ca7cbab4993f295d1089b4860eb32d406fab, stripped
bash: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=0xf199a4a89ac968c2e0e99f2410600b9d7e995187, stripped
c229085928dc19e8d9bd29fe88268504  sh
c229085928dc19e8d9bd29fe88268504  dash
089ed56cd74e63f461bef0fdfc2d159a  bash
Eliah Kagan
  • 119,640
Joel
  • 41
  • 1
  • 1
  • 4

2 Answers2

4

In all remotely recent versions of Ubuntu, /bin/sh is just a symbolic link to /bin/dash. So make sure that whatever is currently called /bin/sh is backed up somewhere if it's important, then delete it and make a new link.

To remove whatever is currently /bin/sh and restore /bin/sh to what it's supposed to be, run these commands:

cd /bin
sudo rm sh
sudo ln -s dash sh
Eliah Kagan
  • 119,640
0

Assuming you still have bash, use bash as sh.

sudo ln -s bash /bin/sh

Then reinstall dash

sudo apt-get install --reinstall dash
geirha
  • 47,279