How do I change my default shell on a AWS instance?

Try using the chsh command.

e.g.

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.


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.


I came here to just add more additional information. If you have troubles when install zsh in Amazon Linux AMI by Amazon, like when you run:

sudo chsh $(which zsh) : // chsh command not found

Then you should install util-linux-user:

sudo yum install util-linux-user

(by default Amazon Linux AMI only has lchsh, but I can not figure how it work).

Then run the following command, it should work:

sudo chsh -s $(which zsh) $(whoami)