How to change default shell to ZSH - chsh says "invalid shell"
Add zsh to /etc/shells
:
command -v zsh | sudo tee -a /etc/shells
You can now use chsh to set zsh as shell:
sudo chsh -s "$(command -v zsh)" "${USER}"
See this documentation: Changing your login shell
You need to add /usr/local/bin/zsh
to /etc/shells
.
First, check if zsh
is listed as a valid shell by
cat /etc/shells
If zsh
is not listed, install it. For example, if you use apt
sudo apt-get install zsh
Do, step 1 again and see the path of zsh
. In my case, both /usr/bin/zsh
and /usr/zsh
is listed.
As @Stéphane Chazelas mentioned in the comment, if you like to compile and install the shell from scratch, be sure to add the path in /etc/shells
.
Change the shell using
chsh -s /usr/bin/zsh
From man page:
-s, --shell SHELL
The name of the user's new login shell. Setting this field to blank causes the system to select the default login shell.
Logout and login again.