Change user's default shell
Reasons
To block or disable normal user logins in Linux using a
nologin
shell.To use a shell wrapper script or program to login user commands before they are sent to a shell for execution.
To meet a user’s demands (wants to use a specific shell), especially those with administrative rights.
Default shells
cat /etc/shells
/bin/sh
/bin/bash
/sbin/nologin
/bin/tcsh
/bin/csh
/bin/dash
Ways to change
usermod
utility
usermod --shell /bin/bash $USER
grep $USER /etc/passwd
chsh
utility
chsh --shell /bin/sh $USER
grep $USER /etc/passwd
/etc/passwd
file
In this method, simply open the /etc/passwd
file using any command line text editor and change the specific users shell.
vi /etc/passwd
When done editing, save and close the file.
Last updated
Was this helpful?