387

I am trying to set ZSH as my default shell, however it keeps reverting back to bash.

I have tried this code:

sudo chsh -s $(which zsh)

I've also tried:

sudo chsh -s /bin/zsh 

Also tried these commands without sudo. Any ideas on what else I need to do. When running ZSH from within bash it loads up and works fine but I'd like to set it as the default shell.

dsg
  • 561
Tom
  • 4,239

8 Answers8

614

Just using chsh:

chsh -s $(which zsh)

without sudo should work. If you use sudo it will change the shell not for your working user but for root

Finally, log out of your computer and log back in.

Troubleshooting:

Pablo Bianchi
  • 17,371
79

I found this on superuser forum

Open /etc/passwd:

sudo vi /etc/passwd

Find the line with your username:

username:x:1634231:100:Your Name:/home/username:/bin/bash

and replace bash with zsh:

username:x:1634231:100:Your Name:/home/username:/bin/zsh

Log out and log in back for the changes to take effect.

53

You may also do this:

open your bashrc file in your favourite editor

nano ~/.bashrc

then add the line below top of the file

exec zsh

It will execute the command every time you load the terminal and run your zsh shell.

muru
  • 207,228
Saddam H
  • 679
21

I had an issue with permissions to change shell under the current user but next helps me (you should set correct 'zsh' folder for your computer):

sudo chsh -s /bin/zsh <myUserName>
Rib47
  • 699
4

If zsh is not /bin/zsh then chsh won't work. On Ubuntu it is /usr/bin/zsh. so doing chsh -s /usr/bin/zsh or chsh -s `which zsh` should work. Also need to re-login to desktop session.

jbp
  • 149
2

As well as chsh (or editing /etc/passwd, which does the same thing), you might need to edit the settings in your terminal emulator (Gnome terminal, Konsole, xfce4-terminal, etc). Your profile will probably have a login shell, which will be run when you open a new tab instead of the shell in /etc/passwd.
In Konqueror it's Settings | Edit Current Profile | Command.

2

Strange, the "accepted" answer didn't work for me as I got

chsh: PAM: Authentication failure

To solve this issue edit your /etc/passwd and make sure it points to the zsh location. (You can find this by running "which zsh") In my case my user called "webmaster" looked like this:

webmaster:x:1001:1001:webmaster,,,:/var/www/webmaster:/usr/bin/zsh
wjandrea
  • 14,504
0

If you are using sssd for Active Directory integration, then you will need to edit /etc/sssd/sssd.conf. Set default_shell to the value of your choice, e.g. /usr/bin/zsh. Also, look at the shell_fallback and override_shell options documented at https://linux.die.net/man/5/sssd.conf Ideally, however, your domain admin would configure the attributes on your user profile in AD.

David Baucum
  • 1,036