How to list available shells for use by command-line?
4 Answers
To list available valid login shells for use at time, type following command:
cat /etc/shells
Example:
pandya@pandya-desktop:~$ cat /etc/shells
# /etc/shells: valid login shells
/bin/sh
/bin/dash
/bin/bash
/bin/rbash
/bin/ksh93
For information about shell visit wikipedia.

- 24,618
-
Note that this will not work for all systems. E.g. Solaris and HP-UX do not have an /etc/shells file by default. – Warwick Jul 02 '14 at 05:25
-
-
2@bernhard - There is a good explanation of /bin/true and /bin/false here link – Warwick Jul 02 '14 at 05:47
You can also use
chsh -l
This will print the list of shells.
Example :-
[anurag@focused ~]$ chsh -l
/bin/sh
/bin/bash
/sbin/nologin
/usr/bin/sh
/usr/bin/bash
/usr/sbin/nologin

- 191
-
4
-
@Pandya can you provide the complete command you are using. You might be using it with combination of other shell methods or constructs like ((...)) or [...] or [[...]] – Anurag Anand Jun 09 '16 at 10:59
-
-
Probably I've http://man7.org/linux/man-pages/man1/chsh.1@@shadow-utils.html – Pandya Jun 09 '16 at 12:00
-
@Pandya http://man7.org/linux/man-pages/man1/chsh.1.html
This provides -l option. Just click on the link on the top of the page, to go to linux-util man page
– Anurag Anand Jun 09 '16 at 13:01 -
@Pandya You can run your the command here and verify. http://www.tutorialspoint.com/execute_bash_online.php – Anurag Anand Jun 09 '16 at 13:03
-
shadow-utils 4.1.5.1
provideschsh
in my case that's why I am getting that error. +1 for correct answer – Pandya Jun 09 '16 at 13:51 -
-
chsh: invalid option -- 'l'
,which chsh
gives/usr/bin/chsh
,dpkg -S /usr/bin/chsh
givespasswd: /usr/bin/chsh
,dpkg-query -l passwd
gives: passwd version 1:4.1.5.1-1. – Progrock Jul 26 '16 at 03:07
On at least OpenBSD and NetBSD:
$ getent shells
On (Ubuntu) Linux and many other Unices (including BSDs):
$ grep '^[^#]' /etc/shells
On Solaris, the file /etc/shells
may not exist. The list of valid shells is contained in the shells(4)
manual. On my vanilla Solaris 11.3 system, this lists the following shells:
/bin/bash /usr/bin/bash /bin/pfbash /usr/bin/pfbash
/bin/csh /usr/bin/csh /bin/pfcsh /usr/bin/pfcsh
/bin/jsh /usr/bin/jsh /sbin/jsh /usr/sbin/jsh
/bin/ksh /usr/bin/ksh /bin/pfksh /usr/bin/pfksh
/bin/ksh93 /usr/bin/ksh93 /bin/pfksh93 /usr/bin/pfksh93
/bin/sh /usr/bin/sh /bin/pfsh /usr/bin/pfsh
/bin/tcsh /usr/bin/tcsh /bin/pftcsh /usr/bin/pftcsh
/sbin/sh /usr/xpg4/bin/sh /sbin/pfsh /usr/xp4/bin/pfsh
/bin/zsh /usr/bin/zsh /bin/pfzsh /usr/bin/pfzsh
/usr/sfw/bin/zsh
It's worth noting that on my installation, neither /usr/sfw/bin/zsh
nor /usr/xp4/bin/pfsh
exists...
A shorter list of valid Solaris shells (duplicates of each shell removed):
/bin/bash /bin/ksh /bin/pfcsh /bin/pfsh /bin/sh
/bin/csh /bin/ksh93 /bin/pfksh /bin/pftcsh /bin/tcsh
/bin/jsh /bin/pfbash /bin/pfksh93 /bin/pfzsh /bin/zsh

- 333,661
If you want to dig into /etc/passwd
, you could do:
cut -d ':' -f 7 /etc/passwd | sort -u
H/T @schrodigerscatcuriosity in https://unix.stackexchange.com/a/631346/40454

- 619
(IFS=: && grep -rl tcsetpgrp $PATH | xargs grep -rl setrlimit)
on a Debian system seems to give a good approximation. – Stéphane Chazelas Jul 02 '14 at 07:29/bin/bash /bin/crash /bin/gdb
(and the symlinks from/usr/bin
). – Cristian Ciupitu Jul 02 '14 at 15:18