How to Change Shell on Amazon Ec2 Linux Instance

How to Change Shell on Amazon Ec2 Linux Instance

I installed c shell using the sudo yum install tcsh command on my brand new amazon EC2 instance, but I'm not sure if it's actually working, since the echo $SHELL command always returns /bin/bash. I'm not sure what I'm doing wrong.

[ec2-user]$ which csh
/bin/csh
[ec2-user]$ sudo csh
[root]# echo $SHELL
/bin/bash
[root]# sudo chsh
Changing shell for root.
New shell [/bin/bash]: /bin/csh
Shell changed.
[root]# echo $SHELL
/bin/bash
[root]# 
0

2 Answers

Amazon Linux 2 doesn't come with chsh installed. So before you can run chsh, you must first install it.

sudo yum install util-linux-user

If you want to change the shell for the account you're currently logged in as (e.g., for the ec2-user or other non-root user that you login with), then you can run chsh interactively. There's no need to use sudo (as another answer said).

To change the shell for someone other than yourself (e.g., root, another user), you do need to use sudo.

There is also no need to reboot. The change will take affect the next time you login. As a matter of safety, you might want to login from a different window (i.e., stay logged in in one window, while testing the shell change in a different window), in case you typo something and can't get back in.

This worked for me:

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

I wanted to change from bash to zsh, but you can use which csh instead. You might need to restart the instance after.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Sophia Al-Mansoor
Author

Sophia Al-Mansoor

Sophia analyzes international trade, startup ecosystems, retail transformation, and supply chain logistics for modern digital publications.