I'm trying to permanently change my shell to zsh using chsh command, but it's not working.

zsh is installed (via apt) and works fine when I invoke it directly from a bash prompt terminal. But I can't get zsh to load in terminals by default, and chsh is doing something weird:

$ echo $SHELL
$ which zsh
$ chsh -s /usr/bin/zsh
$ echo $SHELL
$ grep kurtosis /etc/passwd

It appears chsh has managed to correctly change /etc/passwd, but not the $SHELL env variable. As such, new terminals always start in bash and not zsh.

I'm not sure where to look to troubleshoot this. .bashrc, even though it's not invoked until the shell is specified? Any help appreciated.

  • 1
    Cannot you change shell after you re-logged in the system?
    – vine_user
    Oct 2, 2012 at 2:29
  • Check this answer. Mar 10, 2019 at 19:15
  • 1
    Does this answer your question? How to make ZSH the default shell? Nov 30, 2020 at 22:40
  • The login command generally assigns the SHELL= variable. Bash will, however, set the variable if it is not already set, but I do not think any other shell does.
    – user986805
    Mar 30, 2021 at 10:36
  • The commands you used in your questions actually help me fix my problem :) Thank you for it. Oct 10, 2022 at 10:12

2 Answers 2


You need to log out again for these changes to take effect. The shell defined in the /etc/passwd file is your login shell :-) So you need to log in actually for that.

  • 3
    Thanks. I'm so used to being able to make changes to linux without rebooting, it just didn't occur to me.
    – bgibson
    Oct 3, 2012 at 0:07
  • 1
    I had to actually do a reboot for it to take effect - I guess it was somehow re-connecting me to an existing shell session. Feb 13, 2016 at 18:36
  • While using an ssh connection, even if you do exit, the server may not close the connection and the shell all the way through. So, you may need to kill the processes (ssh and sh) that belong to your user. (I had this problem and it was easy to find the solution but still, I had to come to this post to see that I had to logout.) Aug 2, 2018 at 5:46

There is a couple different problems that can occur here.

Problem 1. The default login shell hasn't been changed in /etc/passwd this can be solved by running chsh -s /usr/bin/zsh which will update /etc/passwd

Problem 2. Bash is still used even after changing the default login shell using chsh -s /usr/bin/zsh and confirming that your shell is actually set to zsh in /etc/passwd. This is caused by recycled ssh sessions. Logging out and logging back in won't fix the issue immediately, the sessions either need to expire or timeout, or you need to kill your session and reconnect. You can reboot, but below is an easier method which helps you find which session to kill.

Check what shell I'm using (/bin/bash) and what shell I should be using (/usr/bin/zsh):

asc@g1:~$ echo $SHELL

asc@g1:~$ cat /etc/passwd|grep asc

Find out my terminal session information:

asc@g1:~$ who
asc      pts/1        2020-01-28 13:08 (

asc@g1:~$ ps aux|grep ssh
root      1220  0.0  0.0  72300  6076 ?        Ss   Jan22   0:00 /usr/sbin/sshd -D
root     32879  0.0  0.0 107988  7224 ?        Ss   13:08   0:00 sshd: asc [priv]
asc      33031  0.0  0.0 107988  3612 ?        S    13:08   0:00 sshd: asc@pts/1
asc      47453  0.0  0.0  14428  1032 pts/1    S+   13:21   0:00 grep --color=auto ssh

Kill my terminal session:

asc@g1:~$ kill 33031

Then SSH back in to the machine and you'll be using ZSH

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .