3

I have accidentally deleted /bin/sh, and I am trying to to re-install it.
If I type sh in the terminal, It says

The program 'sh' can be found in the following packages:
 * bash
 * dash

If I try to apt-get install bash, I get

bash is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 109 not upgraded.

So, how am I supposed to get /bin/sh back?

Kevin
  • 40,087
  • 16
  • 88
  • 112
Fingolfin
  • 213
  • 1
  • 3
  • 10

2 Answers2

4

You can do

apt-get --reinstall install bash
enzotib
  • 50,671
  • 14
  • 120
  • 105
  • I tried that and I got the following: >E: Sub-process /usr/sbin/dpkg-preconfigure --apt || >true returned an error code (100) >E: Failure running script /usr/sbin/dpkg-preconfigure >--apt || true – Fingolfin Nov 26 '11 at 22:18
  • @AdelCKod Try `ln -s bash /bin/sh`, and then enzotib's answer. Also, learn from whatever mistake you made that resulted in the removal, and try to never make it again. – jw013 Nov 26 '11 at 22:53
  • @jw013 No, it works, but is not the default. @Arcege is right: `/bin/sh` was not `bash` in his **Debian** system, it was `dash`, the _Debian Almquist Shell_. – admirabilis Jan 23 '12 at 07:14
4

Try sudo ln -s dash /bin/sh. The "dash" package should already have set this symlink in its post-installation routines.

Arcege
  • 22,287
  • 5
  • 56
  • 64
  • I think you mean bash...? – amphetamachine Nov 27 '11 at 06:26
  • `/bin/sh` is the Bourne shell equivalent, which in the case of the OP, is `dash`. – Arcege Nov 27 '11 at 07:04
  • I meant "I think you mean `sudo ln -s bash /bin/sh`." – amphetamachine Nov 27 '11 at 17:49
  • 1
    No, i meant what I said: `lrwxrwxrwx 1 root root 4 2011-05-03 11:01 /bin/sh -> dash` on Ubuntu; on Solaris and FreeBSD, `/bin/sh` was a smaller, statically linked version of the Bourne shell; I can't remember about HP-UX, AIX and IRIX, but it wasn't `bash`. As I said, `/bin/sh` should be the closest to the Bourne shell. If using bash syntax, then `#!/bin/bash` should always be specified. – Arcege Nov 27 '11 at 19:18