Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I want to change my shell from the default bash shell to zsh on my Amazon EC2 instances. How do I go about doing it? Thanks!

share|improve this question

2 Answers 2

up vote 100 down vote accepted

Try using the chsh command.


chsh -s /bin/zsh

You can confirm the location of zsh by running whereis zsh, or alternatively simply run

chsh -s $(which zsh)

If you want to change the shell for a user account other than the one you're logged into, you'll need to run it as root, so to change john's shell, do:

sudo chsh -s $(which zsh) john

Note that you'll need to log out and log back in for the change to go into effect. If you're using Gnome or some other window manager, you'll need to completely log out of that session as well—simply closing and opening your terminal is insufficient.

share|improve this answer
I did try that, but with the root user!! My AMI Image has ubuntu rather than root. Had to switch to ubuntu user to change the shell! Thanks for the hint :) –  Shripad Krishna Jan 11 '11 at 11:45
@Paddy if you are root you can change it for another user by running chsh -s /bin/zsh username. –  John T Jan 11 '11 at 11:47
Awesome :) Much easier. Thanks for that info too. –  Shripad Krishna Jan 11 '11 at 11:48
I'm getting: chsh: /usr/local/bin/zsh is an invalid shell –  Pineapple Under the Sea Feb 26 '13 at 4:13
@We are the World: You need to add /usr/local/bin/zsh as a new line to /etc/shells –  Nate Parsons Jun 4 '13 at 17:54

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
It's better to use chsh, but if you're really going to edit /etc/passwd by hand, at least use the vipw command. –  Valmiky Arquissandas Aug 14 '14 at 2:58
I don't have chsh on my machine. Also, for some weird reason my /etc/passwd file is regularly being overwritten by the default one. Do you know why this could be happening? –  Georgii Oleinikov Aug 14 '14 at 16:44

Your Answer


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.