The /etc/shells file

As you know, all the files from /etc are very important for the Unix / Linux systems.

Watch Free Movies

The /etc/shells file contains a list of all the shells available in the system.

Sample of /etc/shells file:

$ cat /etc/shells
# /etc/shells: valid login shells
/bin/csh
/bin/sh
/usr/bin/es
/usr/bin/ksh
/bin/ksh
/usr/bin/rc
/usr/bin/tcsh
/bin/tcsh
/usr/bin/esh
/bin/dash
/bin/bash
/bin/rbash
/bin/zsh
/usr/bin/zsh
/usr/bin/screen

This list updates each time you install a new shell.

On PCBSD 9.0, I have installed bash but did not find it in the /etc/shells file after installation. So I added the line “/bin/bash” in /etc/shells by hand, in order to set it as my user’s default shell.

$ sudo echo "/bin/bash" >> /etc/shells

To create a user with a customized login shell, use (as root): useradd -s /path/to/shell username

To change a user’s default shell on Linux and *BSD systems, use chsh or usermod:

Syntax (as root): chsh -s /path/to/shell username
Syntax (as root): usermod -s /path/to/shell username

I create the testuser with zsh as it’s default login shell and change the login shell to /bin/ksh and /bin/tcsh, with both the chsh and usermod tools:

$ sudo useradd -s /bin/zsh testuser
$ < /etc/passwd grep testuser
testuser:x:1014:1038::/home/testuser:/bin/zsh
$ sudo chsh -s /bin/ksh testuser
$ < /etc/passwd grep testuser
testuser:x:1014:1038::/home/testuser:/bin/ksh
$ sudo usermod -s /bin/tcsh testuser
$ < /etc/passwd grep testuser
testuser:x:1014:1038::/home/testuser:/bin/tcsh

To find out your user’s default shell, you can also use echo $SHELL, or finger username | grep -i shell , instead of grepping the user’s name from the /etc/passwd file.

$ su testuser
$ echo $SHELL
/bin/tcsh
$ finger testuser | grep -i shell
Directory: /home/testuser Shell: /bin/tcsh

Related articles you may want to read:

Scroll to Top