Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question
add comment

2 Answers 2

up vote 4 down vote accepted

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

share|improve this answer
    
I think you mean bash...? –  amphetamachine Nov 27 '11 at 6:26
    
/bin/sh is the Bourne shell equivalent, which in the case of the OP, is dash. –  Arcege Nov 27 '11 at 7: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
add comment

You can do

apt-get --reinstall install bash
share|improve this answer
    
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 –  xci13 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. –  Teresa e Junior Jan 23 '12 at 7:14
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.