How to list available shells for use by command-line?

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

To list available valid login shells for use at time, type following command:

cat /etc/shells


pandya@pandya-desktop:~$ cat /etc/shells
# /etc/shells: valid login shells

For information about shell visit wikipedia.

  • 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 2 '14 at 5:25
  • Why do I have /bin/true and /bin/false in this list? – Bernhard Jul 2 '14 at 5:33
  • 2
    @bernhard - There is a good explanation of /bin/true and /bin/false here link – Warwick Jul 2 '14 at 5:47

You can also use chsh -l This will print the list of shells.

Example :-

[anurag@focused ~]$ chsh -l

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

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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.