Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 43 down vote accepted

If you use sudo it will change the shell not for your working user but for root. Just using

chsh -s $(which zsh)

without sudo should work (but you need to login again to see the change).

share|improve this answer
6  
I have the same problem and the answer doesn't solve it – Aswin Murugesh Jul 21 '13 at 16:11
    
@AswinMurugesh Check my answer – Shailesh Kalamkar Aug 11 '15 at 5:30
2  
you can also run sudo chsh -s /bin/zsh userName – Dr Gorb Sep 30 '15 at 10:49
1  
Note: I had to restart my system before this would take effect. – KevinO Oct 12 '15 at 0:38

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.

share|improve this answer
1  
You should be very careful with this approach - it's not usually the best idea to go mucking around with /etc/passwd – Thomas W. Jan 7 at 13:13

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.

share|improve this answer
    
On my Ubuntu VPS it's /bin/zsh – Wilhelm Erasmus Dec 9 '15 at 12:39

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: enter image description here

share|improve this answer
    
I believe it's supposed to ask for a password. I got the same error on my previous mint install. Current one worked fine though – Wilhelm Erasmus Dec 9 '15 at 12:40

Easiest way is to follow the steps from this tutorial: In your terminal/cli/console:

$ sudo apt-get update
$ sudo apt-get install zsh
$ sudo apt-get install git-core
$ curl -L http://install.ohmyz.sh > install.sh
$ sh install.sh

This worked perfectly for me.

share|improve this answer

You may also do this:

open your bashrc file in your favourite editor

sudo 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.

share|improve this answer
    
and it will also break all your non-interactive jobs (scp for example). – Jakuje Mar 11 at 16:45

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.