2 Ways to Change a User’s Login Shell

In this article I will show you 2 ways for changing a user’s login shell, with the usermod and chsh tools.

Watch Free Movies

Before you set a new shell, check if you have the needed shell listed in the /etc/shells file. If not, add it by hand.

Check if you have the shell_name shell listed in /etc/shells:

$ grep shell_name /etc/shells

Add shell_name to /etc/shells, as root:

# echo /path/to/shell_name >> /etc/shells

Set a new default shell, with chsh:

chsh -s /path/to/shell username

Set a new default shell, with usermod:

usermod -s /path/to/shell username

Examples:

Set zsh as a default shell:

$ whereis zsh
zsh: /bin/zsh /usr/bin/zsh /etc/zsh /usr/lib/zsh /usr/share/zsh /usr/share/man/man1/zsh.1.gz
$ sudo chsh -s /bin/zsh username

Set tcsh as a default shell:

$ whereis tcsh
tcsh: /bin/tcsh /usr/bin/tcsh /usr/share/man/man1/tcsh.1.gz
$ sudo usermod -s /bin/tcsh username

Set nologin as default shell (for Debian systems):

$ whereis nologin
nologin: /usr/sbin/nologin /usr/share/man/man8/nologin.8.gz /usr/share/man/man5/nologin.5.gz
$ sudo chsh -s /usr/sbin/nologin username

Set false or true as default shell:

$ whereis true
true: /bin/true /usr/share/man/man1/true.1.gz
$ whereis false
false: /bin/false /usr/share/man/man1/false.1.gz
$ chsh -s /bin/false username
$ usermod -s /bin/true username

Read more about the /bin/false and /usr/sbin/nologin here.

If you want the user mike99 to use vim only, make vim as his default shell.

$ sudo chsh -s /usr/bin/vim mike99

Scroll to Top