The shell on a Linux system is the layer that interprets the commands being executed by the user, and translates them into a language that the operating system can understand. The Bash shell is the default one in Linux, and typically what all users become familiar with first. But there are a lot of other shells that can be used, too; like sh, zsh, ksh, csh, and tcsh, to name a few.
Knowing what shell you are currently using is important, since each one will interpret commands a little differently. Some of them expect a different syntax than others. For example, a Bash script may work perfectly fine in Bash, but produce errors when executed with the sh shell. In this tutorial, we will show you how to check what shell you are using on Linux.
In this tutorial you will learn:
- How to check what shell you are currently using
- How to check a user’s default shell
- How to generate a list of available shells on the system
- How to change to a different shell
|Category||Requirements, Conventions or Software Version Used|
|System||Any Linux distro|
|Other||Privileged access to your Linux system as root or via the
# – requires given linux commands to be executed with root privileges either directly as a root user or by use of
$ – requires given linux commands to be executed as a regular non-privileged user
How to check what shell I’m using – example commands
Linux user accounts can be configured to log in to a particular shell by default (for example, with the usermod command), or they can switch to a different shell after being logged in.
Let’s see how to check our current shell, display a list of usable shells, and switch to a different shell in Linux.
- First, let’s check what shell we are currently using. We can rely on the
SHELLenvironment variable for this by executing the following command:
$ echo $SHELL /bin/bash
The command shows us that we are using the Bash shell, which is located at
- Next, let’s see what our default shell is by looking inside of the
/etc/passwdfile. We will check specifically for user
linuxconfigby piping to the
$ cat /etc/passwd | grep linuxconfig
The final field in the output will show what shell a user is using by default when they log in.
- We can get a full list of the shells installed on the system by executing the following command. Any of these are available to use, except some, like the /sbin/nologin shell, which serve a specific purpose and are not meant to be usable by people.
$ cat /etc/shells
- Now, let’s see how we can change to a different shell, in case we recognize one from the list above that we would like to use instead of our current one. For this, we can just execute the full path of the shell we want to use. This command will log us into the sh shell.
In this tutorial, we saw how to check what shell you are currently using on a Linux system. Experienced users may come to appreciate some of the functions offered outside of the Bash shell, and have the desire to switch every once in a while. Being able to quickly identify and switch between shells allows you to get the most out of your Linux command line experience, and always choose the right tool for the job.