I have replaced sh with zsh with the following commands:

$ sudo mv /bin/sh /bin/sh1
$ sudo ln -s /usr/bin/zsh /bin/sh
$ ls -l /bin/sh
lrwxrwxrwx 1 root root 12 Jul  6 20:48 /bin/sh -> /usr/bin/zsh
$ which sh
$ sh
$ exit
$ zsh
mpc% exit

As you can see, the sh command doesn't open a zsh shell although it has been linked. The question is why? How can I fix that?


Why not change your user's default shell using chsh instead.

$ chsh -s /usr/bin/zsh



It's supposed to do that. If you start it as sh, it assumes you want something that's mostly compatible with other shells called sh, and runs in a compatibility mode.

See http://zsh.sourceforge.net/Doc/Release/Invocation.html#Compatibility:

Zsh tries to emulate sh or ksh when it is invoked as sh or ksh respectively; [...]

In sh and ksh compatibility modes the following parameters are not special and not initialized by the shell: ... prompt, PROMPT, ...

The usual zsh startup/shutdown scripts are not executed.

I'm not sure if it's possible to have not work in compatibility mode when called as sh, but that might break a number of scripts on your system that assume /bin/sh is just sh, not Zsh.

Probably best to run it as zsh instead.

  • Correct, if called sh, it is mostly shell compatible, but slower. So you may suffer from longer boot times. – schily Jul 6 '18 at 17:19

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.