Linux – How to change the shell on an Amazon EC2 Linux instance

How to change the shell on an Amazon EC2 Linux instance… here is a solution to the problem.

How to change the shell on an Amazon EC2 Linux instance

I

installed the c shell using the sudo yum install tcsh command on a brand new Amazon EC2 instance, but I’m not sure if it really works because 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]# 

Solution

Amazon Linux 2 does not have chsh installed. So before running chsh, you must install it first.

sudo yum install util-linux-user

If you want to change the shell of your currently logged in account (for example, ec2-user or another non-root user you are logged in), you can run chsh interactively. There is no need to use sudo (as the other answer says).

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

A reboot is also not required. The changes will take effect the next time you sign in. For security reasons, you may want to log in from a different window (that is, stay logged in in one window while testing shell changes in a different window) in case you make a typo and cannot return.

Related Problems and Solutions