2

I have installed Zsh via running:

sudo apt-get install zsh

Using the following guide for installing Zsh provided by oh-my-zsh I attempted to set it as my default shell, namely I ran:

chsh -s $(chsh -l | grep "zsh" -m 1)

which gave me the error:

chsh: invalid option -- 'l'

I ran:

sudo gedit /etc/shells

so I could check that zsh was listed there and it was. I also tried Florian's answer to a previous question, namely: chsh -s /bin/zsh but echo $SHELL still returned the same output: /bin/bash. /bin/zsh does exist on my system if you are wondering, as I tested this by running /bin/zsh which started Zsh.

Josh Pinto
  • 7,919

1 Answers1

3

you can do it using

chsh -s /bin/zsh

It will prompt you to enter your password. Your default login shell is /bin/zsh now.

man chsh

The chsh command changes the user login shell. This determines the name of the users initial login command. A normal user may only change the login shell for her own account, the superuser may change the login shell for any account

This command will change the default login shell permanently.

Why $SHELL not change?!

The SHELL variable is set by the process that logs you in. It is set to the login shell value set in the passwd file (/etc/passwd). It is not meant to reflect the shell you're currently using.

To print the shell in use you have to run

 echo $0 

This will shows the shell name used.

So how to change Login Shell

use the command chsh without options

$ chsh 
Password: 

Changing the login shell for maythux
Enter the new value, or press ENTER for the default
    Login Shell [/bin/bash]: 

you can enter now your /bin/zsh.

Now log out then login again

$ echo $SHELL

/bin/zsh
Maythux
  • 84,289