How to find list of available shells by command-line?

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

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

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

cat /etc/shells

Example:

<a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="66160708021f0726160708021f074b0203150d120916">[email protected]</a>:~$ cat /etc/shells
# /etc/shells: valid login shells
/bin/sh
/bin/dash
/bin/bash
/bin/rbash
/bin/ksh93

For information about shell visit wikipedia.

Method 2

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

Example :-

[<a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="6d0c03181f0c0a2d0b020e181e0809">[email protected]</a> ~]$ chsh -l
/bin/sh
/bin/bash
/sbin/nologin
/usr/bin/sh
/usr/bin/bash
/usr/sbin/nologin

Method 3

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

Method 4

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


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x