Listing All the Available Shells in Your Linux System

Linux TLDR
Last Updated:
Reading time: 3 minutes

Bash is the most popular shell implementation program that most modern Linux systems like Debian and Ubuntu ship out of the box, unlike ZSH and Fish.

However, operating systems like Kali Linux and macOS took a step forward by providing ZSH as the default login shell for their systems because of its features and functionality.

Most of the time, Bash and its derivative shells like ZSH and Fish share common syntax and functionality, except for a few things that do not affect regular interactive users.

However, this minor difference might affect shell script writers who want to write script in Bash for mass users; having other shells might become a stepping stone in their way.

That’s why you should know all the shells in your and other systems, and as a shell script user, you should also know the existing shell in your Linux system.

Apart from them, a curious Linux user who wants to explore other shells can also check the existing available shells on their Linux system by following this guide.

Tutorial Details

DescriptionListing All Available Shells in Linux
Difficulty LevelLow
Root or Sudo PrivilegesNo
Host System and ArchitectureUbuntu 22.10 (x64)
OS Compatibility Ubuntu, Manjaro, Fedora, etc.
Prerequisitescat, grep, awk, chsh, printenv, echo
Internet RequiredNo

Listing All the Available Shells in Your Linux System

There are several ways to find the available shells on your Linux system from the command line without requiring any extra tools, starting with

Reading the /etc/shells file

The traditional way to check all the available shells in your system is by reading the “/etc/shells” file using the cat command.

$ cat /etc/shells

Output:

Listing the available shells using the cat command

Using the Grep Command with Regular Expressions

The grep command with regular expressions will only list the shell path (that starts with a “/” slash) in the “/etc/shells” file, ignoring the first commented line.

$ grep '^[^#]' /etc/shells

Output:

Listing available shells using the grep command

Using the Chsh Command

The chsh command is usually used to change the default login shell, but the same command with the “-l” or “--list-shells” flag will list the available shells in your Linux system.

πŸ“
The following command might not work in the Debian and Ubuntu systems, but apart from them, in Red Hat, Manjaro, Fedora, etc., it works without any issues.
$ chsh -l

Output:

Listing all available shells using the chsh command

Listing Only the Single Result of the Duplicate Shell Occurrences

While reading the “/etc/shells” file, it will list all the available shells in all known locations, with single shells appearing multiple times (due to different paths).

However, you can remove the path and use the shell names to print the unique result without repeating a single shell multiple times, as shown.

$ grep '^[^#]' /etc/shells | awk -F "/" '{print $NF}' | uniq

Output:

Listing only the unique shell names

Command breakdown:

  • grep '^[^#]' /etc/shells: It will list all the shell paths that start with a “/” slash.
  • awk -F "/" '{print $NF}': It will use the “/” slash in the path as a separator to create different columns and list the last column containing the shell name.
  • uniq: List only the unique shell name without repeating it multiple times.

Listing All the Users with Their Default Login Shell

You can easily find out the default login shell for all users by reading the “/etc/passwd” file using the awk command, as shown.

$ awk -F ":" '{print "User: "$1", Shell: "$7}' /etc/passwd

Output:

Listing the default login shell for all users

Note that this file also contains users created by the system services, applications, or programs that can give you some unnecessary information.

To filter out the result, specify the username with the grep command to find the default login shell for a specific user.

$ awk -F ":" '{print "User: "$1", Shell: "$7}' /etc/passwd | grep linuxtldr

The above command will only list the default login shell for the “linuxtldr” user, as shown.

Listing the default login shell for a specific user

Printing the Default Login Shell for an Existing User

You can read the $SHELL environment variable or use the echo command to find out your own existing login shell, as shown.

$ printenv SHELL

#OR

$ echo $0

Output:

Printing the existing user login shell

Final Tip!

The default login shell shipped with your Linux distribution will surely be present in this configuration file, and manually installed shells will also add their paths to this file.

However, in some rare situations, like when it happens to me when I install the Korn shell, the binary path of this shell is not added to this configuration file. In this case, I have to use the which command to find the binary path.

Still, it will rarely happen to you, but if it does, don’t hesitate to ask for help from us in the comment section.

Join The Conversation

Users are always welcome to leave comments about the articles, whether they are questions, comments, constructive criticism, old information, or notices of typos. Please keep in mind that all comments are moderated according to our comment policy.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.