How to reinstall /bin/sh

25,568

Solution 1

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

Solution 2

You can do

apt-get --reinstall install bash
Share:
25,568

Related videos on Youtube

Fingolfin
Author by

Fingolfin

Updated on September 18, 2022

Comments

  • Fingolfin
    Fingolfin over 1 year

    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?

  • Fingolfin
    Fingolfin over 12 years
    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
  • jw013
    jw013 over 12 years
    @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.
  • amphetamachine
    amphetamachine over 12 years
    I think you mean bash...?
  • Arcege
    Arcege over 12 years
    /bin/sh is the Bourne shell equivalent, which in the case of the OP, is dash.
  • amphetamachine
    amphetamachine over 12 years
    I meant "I think you mean sudo ln -s bash /bin/sh."
  • Arcege
    Arcege over 12 years
    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.
  • Rizwan Khan
    Rizwan Khan over 12 years
    @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.