This may sound silly but I want to uninstall sh (for research purposes) and replace it with my own shell. Is this actually possible?

Many scripts and programs seem to have it hardcoded in, so I'm in doubt as to its viability.

  • 8
    /bin/sh is a symlink, so you could just change it to point to your own shell instead. Beware that you might seriously break things if your own shell doesn't work correctly.
    – JonasCz
    Jun 28 '16 at 14:40
  • 3
    @JonasCz Yeah. He might want to test in a VM with snapshots. Jun 28 '16 at 15:02
  • 3
    Doing it this way is a very bad idea. I recommend using the chsh command, chsh -s /path/to/shell.
    – grooveplex
    Jun 28 '16 at 15:20
  • 2
    And what exactly do you mean by research purposes ? If you have no idea what you're doing, you might seriously break your system, and then no lol-cats for you no more Jun 28 '16 at 23:05


This answer is only provided for research and to further knowledge of Ubuntu Linux. Running any commands in this answer may very well destroy your system entirely. Make sure you're in a VM or a backup. I am not responsible if you break your system.

The command sh is provided by dash, by way of a symlink:

$ ll /bin/sh
lrwxrwxrwx 1 root root 4 Jun  1 08:33 /bin/sh -> dash*

$ which sh

$ dpkg -S /bin/dash
dash: /bin/dash

$ dpkg -S /bin/sh
diversion by dash from: /bin/sh
diversion by dash to: /bin/sh.distrib
dash: /bin/sh

To remove it, run the below command:

sudo apt remove dash

APT will kick you back with the following error message:

You are about to do something potentially harmful.
To continue type in the phrase 'Yes, do as I say!'

If you are really willing to destroy your system, type that in and press Return.

Ubuntu will then uninstall bash, lightdm, and the ubuntu-desktop meta-package (as well as all packages that depend on those three), because they all have a dependency on dash. Unless your current shell works perfectly, your system will be unusable after you kill the last instance of bash or dash.

If you actually follow through with this command, the only way to restore the proper files is to boot into a Live CD and re-install the packages through a chrooted recovery session.

If you're really lucky, you might still be able to repair your system live by re-installing the packages, provided you still have a root shell open. Systems have recovered from worse before, but luck really needs to be on your side for that.

Instead, I would suggest you re-make the /bin/sh symlink to point to your shell. In that case, you can just restore back to dash if something goes really really wrong. Do this by running these commands:

sudo -s
cd /bin
rm sh
ln -s /path/to/your/shell sh
chmod 777 sh

Restore back to dash by repeating these steps, but specifying dash instead of your own shell. Or just run sudo apt install --reinstall dash. You might need to specify a custom init to do this.


I would install your own shell alongside SH. Uninstalling SH is a VERY bad idea, as numerous programs and scripts rely on it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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