The file /etc/shells the full paths for all the login shells available on the system. So, to set the particular shell, the shell entry must be present in /etc/shells file.
# cat /etc/shells /bin/sh /bin/bash /sbin/nologin /bin/dash /bin/tcsh /bin/csh
You can also use the chsh -list or chsh -l command to list out the available shells on the system:
# chsh --list /bin/sh /bin/bash /sbin/nologin /bin/dash /bin/tcsh /bin/csh
Change login shell at the time of creating user
To set the particular shell at the time of creating user, below command can be used:
# useradd -s [shell] [username]
For example to set the shell of user testuser to /bin/bash :
# useradd -s /bin/bash testuser
Change login shell of existing user
To change existing user’s shell, below command can be used:
# chsh -s [shell] [user]
For example, to change the shell of testuser to /bin/bash using chsh command:
# chsh -s /bin/bash testuser
Another way to change the shell is to use the command usermod. The syntax to change shell of the user is :
# usermod -s [shell] [user]
For Example, to change the shell of testuser to /bin/bash using usermod command:
# usermod -s /bin/bash testuser
Verify
Verify the current login shell of the user with either of the below methods:
# echo $SHELL /bin/bash
# cat /etc/passwd | grep testuser testuser:x:8152:9152::/home/testuser:/bin/bash