What is a login shell for?

In practical terms, the selected login shell determines the default shell for the user. Although, of course, nothing prevents you from running any other shell installed on your system.

How to find out what shells are installed on the system

To change the default shell for a user, you need to know which shells are available and what they are named correctly.

One way to find out the correct shell names and paths to executable files is to run the following command:

chsh -l

But the previous command does not work on all distributions (works on Arch Linux, but does not work on Debian derivatives).

Therefore, you can use the universal method - look at the contents of the /etc/shells file:

cat /etc/shells

The shells file contains the paths to the active login shells.

/etc/shells is a text file that contains the full paths to valid login shells. This file is viewed by chsh and can be requested by other programs.

Keep in mind that there are programs that access this file to find out if the user is a regular user; for example, FTP daemons have traditionally denied access to users with shells not included in this file.

Program for changing default user shell - chsh

chsh - Change the user's login shell permanently.

If you want to temporarily change the shell, then install it and run it. Examples of commands for launching various shells:


chsh is used to change the login shell. If shell is not listed on the command line, chsh prompts for it.

chsh supports non-local entries (kerberos, LDAP, etc.) if linked to libuser, otherwise use ypchsh, lchsh, or any other implementation for non-local entries.

Command syntax:

sudo chsh -s SHELL

As the SHELL, you need to specify one of the shells, as they are listed in the /etc/shells file.

chsh will accept the full path to any executable file on the system.

The default behavior for non-root users is to accept only shells listed in the /etc/shells file and issue a warning to the root user. It can also be configured at compile time to only issue a warning to all users.

Changing shell with usermod

The usermod utility with the -s option changes the shell for the specified user.

For example, to block the root user, use the following command:

sudo usermod -s /usr/sbin/nologin root

To assign a Bash shell to the root user:

sudo usermod -s /usr/bin/bash root

To assign a ZSH shell to the root user:

sudo usermod -s /usr/bin/zsh root