Change shell (chsh) for Amazon Linux 2

chsh does not come with the EC2 Amazon Linux 2 distro. If you want to install zsh or want to change default shell to your favorite, you might have to do additional step to make it works.

Run this command on your EC2 instance:

sudo yum install util-linux-user

After that, you can now change your default shell to zsh using chsh:

chsh -s $(which zsh)

In case you are connecting to your EC2 instance using a key pair and Amazon Linux 2 asking for your password, set your user password using this command:

sudo passwd ec2-user

The shell will prompt you to enter the current password, just don't type anything and press Enter. You'll be able to enter your new password and a confirmation of your password.

After changing, you can now change your default shell again!