Windows Subsystem for Linux: Changing the Shell

So, you installed the Windows 10 anniversary update and rushed directly to install the Windows Subsystem for Linux?

If you wonder how to change the bash shell to another shell there is a simple way of doing it.

chsh is not enough

Running chsh is not enough, we need a little script that starts our desired shell for us.

However, to keep the good practice we are setting the shell using chsh and execute the shell later:

chsh -s /bin/sh $LOGNAME

Executing the new shell from .bashrc

We add this litte script to our ~/.bashrc:

if [ $PPID == 1 ]; then
    SHELL=$(getent passwd $LOGNAME | cut -d: -f7)
    if [ -e $SHELL ]; then
            $SHELL
            exit
    else
            echo "$SHELL" not found!
    fi
fi

It runs our shell that was set by chsh.

Note for the root user it is enough to use chsh, since sudo runs the default shell by itself.

Written by

Tobias Salzmann