chsh Command Examples in Linux

The chsh (change shell) command sets your login shell program. Invoked without a username, chsh affects your account; invoked with a username (by root), it affects that user. With no options, chsh will prompt you for the desired information.

$ chsh
Changing shell for smith.
Password: *******
New shell [/bin/bash]: /bin/tcsh

The new shell must be listed in /etc/shells.

chsh Command Examples

1. To change your login shell:

# chsh -s /bin/bash 

2. To print the list of shells:

# chsh -l 

3. To print the usage message and exit:

# chsh -u

4. To print the version information:

# chsh -v 

Tips

– After changing shells, you might have problems running some commands or have a prompt or display that’s not as good as the original. That’s likely a result of your default shell being carefully customized by your system administrator.
– Some systems don’t let users use chsh to change shells. If this is the case, you’ll need to email your system administrator and ask for a change, or see if there are alternative methods.

Final Thoughts

chsh is used to change your login shell. If a shell is not given on the command line, chsh prompts for one. All valid shells are listed in the /etc/shells file. For example:

$ chsh -l
/bin/bash
/bin/sh
/bin/ash
/bin/bsh
/bin/tcsh
/bin/csh
/bin/ksh
/bin/zsh
Related Post