I've just installed zsh on Ubuntu 20.04 and decided to change it back to bash. I tried common way which is chsh but it doesn't work.
Reference:changing shell from zsh to bash
Current shell
wolf@linux:/home/wolf $ echo $SHELL
/bin/zsh
wolf@linux:/home/wolf $ 1st attempt
wolf@linux:/home/wolf $ sudo chsh -s /bin/bash
wolf@linux:/home/wolf $ echo $SHELL
/bin/zsh
wolf@linux:/home/wolf $2nd attempt
wolf@linux:~$ sudo chsh --shell=/bin/bash $USER
wolf@linux:~$ echo $SHELL
/bin/zsh
wolf@linux:~$ 3rd attempt
wolf@linux:~$ chsh -s $(which bash)
Password:
wolf@linux:~$ echo $SHELL
/bin/zsh
wolf@linux:~$ Even bash and exec bash do not work
wolf@linux:/home/wolf $ bash
wolf@linux:~$ echo $SHELL
/bin/zsh
wolf@linux:~$ exec bash
wolf@linux:~$ echo $SHELL
/bin/zsh
wolf@linux:~$ 2 2 Answers
chsh changes the shell field in the password database, which is read on login. To see the effect of the change, you need to start a new login session - for example with su -:
Ex. confirm current login shell is bash:
steeldriver@DESKTOP:~$ getent passwd steeldriver
steeldriver:x:1000:1000:,,,:/home/steeldriver:/bin/bash
steeldriver@DESKTOP:~$ echo $SHELL
/bin/bashChange the shell - the password database is updated immediately but the value of $SHELL doesn't change
steeldriver@DESKTOP:~$ chsh -s /usr/bin/zsh
Password:
steeldriver@DESKTOP:~$ getent passwd steeldriver
steeldriver:x:1000:1000:,,,:/home/steeldriver:/usr/bin/zsh
steeldriver@DESKTOP:~$ echo $SHELL
/bin/bashNow start a new login session:
steeldriver@DESKTOP:~$ su - steeldriver
Password:
steeldriver@DESKTOP-SPDO14V ~ % echo $SHELL
/usr/bin/zsh chsh -s /bin/bash(enter password when prompted)- Log out
- Log back in
echo $SHELLto confirm