18

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
28

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.

  • 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
6

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
2

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

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.