Programming
linux bash shell environment tcsh
Updated Sun, 17 Jul 2022 08:07:38 GMT

Changing default shell in Linux


How is it possible to change the default shell? The env command currently says:

SHELL=/bin/tcsh

and I want to change that to Bash.




Solution

Try linux command chsh.

The detailed command is chsh -s /bin/bash. It will prompt you to enter your password. Your default login shell is /bin/bash now. You must log out and log back in to see this change.

The following is quoted from man page:

The chsh command changes the user login shell. This determines the name of the users initial login command. A normal user may only change the login shell for her own account, the superuser may change the login shell for any account

This command will change the default login shell permanently.

Note: If your user account is remote such as on Kerberos authentication (e.g. Enterprise RHEL) then you will not be able to use chsh.





Comments (5)

  • +0chsh: can only change local entries; use ypchsh instead. Then ypchsh doesn't have any -s option — Oct 24, 2012 at 09:31  
  • +0 – @ShaktiMalik I believe the configure file is /etc/passwd, but I didn't double check it. — Feb 11, 2014 at 13:18  
  • +0You must log out and log back in to see this change. — Jul 06, 2014 at 22:03  
  • +0 – In my case, I had root access but didn't want to mess with any configurations on the actual host. I added exec /bin/bash to ~/.profile and this allowed me to login directly to bash without making any changes to the server. (The original default shell was just /bin/sh) — Aug 18, 2014 at 19:38  
  • +2 – @BCqrstoO Thank you for this. But what if you type exit in bash? Will you logout the server directly or just exit the bash and into the sh and another exit required to logout the server? — Aug 19, 2014 at 04:32