Joey
Joey

Reputation: 1679

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]# 

Upvotes: 5

Views: 7644

Answers (2)

Paco Hope
Paco Hope

Reputation: 450

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.

Upvotes: 8

stelo
stelo

Reputation: 756

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.

Upvotes: 7

Related Questions