How to Check Which Shell You Are Using on Linux

Check Which Shell You Are Using on Linux

In the vast world of Linux, the shell plays a pivotal role. It is the command-line interface that allows users to interact directly with the operating system. Whether you’re executing commands, running scripts, or managing files, the shell is your gateway to Linux’s powerful functionality. With a variety of shells available, such as Bash (Bourne Again Shell), Csh (C Shell), Ksh (Korn Shell), and Zsh (Z Shell), each offers unique features and syntax to cater to different user preferences. This article will guide you through the process of determining which shell you are currently using on your Linux system, providing step-by-step instructions, troubleshooting tips, and additional resources to enhance your Linux experience.

Understanding the Shell in Linux

The shell is an integral part of any Linux system. It acts as an intermediary between the user and the kernel, the heart of the operating system. When you type a command into the shell, it interprets this command and translates it into an action that the operating system can perform. This process is what allows you to interact with your Linux system.

Different shells offer unique features and syntax. For instance, Bash is renowned for its scripting capabilities, while Zsh is known for its robust command-line editing features. Understanding these differences can help you choose the shell that best suits your needs and preferences.

Check Which Shell You Are Using on Linux

Determining which shell you are currently using in Linux can be achieved through several methods. Each method has its strengths and limitations, and understanding these can help you choose the most reliable method for your specific situation.

Using the Echo Command

One of the most common methods to check your current shell is by using the echo command with the $SHELL or $0 variable. The $SHELL variable typically contains the path to the default shell, while $0 often prints the name of the current shell.

To use this method, open your terminal and type the following command:

echo $SHELL


echo $0

The output will typically display the path to the shell executable or the shell name.

Using the PS Command

Another method involves using the ps command, which provides information about the currently running processes, including the shell. To use this method, type the following command into your terminal:

ps -p $$

The output will display information about the current shell process, including its PID (Process ID) and the shell name.

Viewing the /etc/passwd File

The /etc/passwd file contains user account details, including the default shell. To view this file, use the cat command followed by your username. Here’s how:

cat /etc/passwd | grep `whoami`

The output will display a line containing your user account details. The default shell is listed at the end of this line.

Using the Special Shell Parameter

The special shell parameter $$ can be used to display the process ID of the current shell instance. To use this method, type the following command into your terminal:

echo $$

The output will display the process ID of the current shell. You can then use the ps command to determine the shell name associated with this process ID.

While these methods are generally reliable, they have their limitations. For instance, the echo $SHELL command only displays the default shell, not the current shell. Similarly, the ps command might not provide accurate results if you have multiple shell instances running.

Understanding the Output of Shell Checking Commands

The output of the commands used to check the shell typically displays the path to the shell executable or the shell name. For instance, the echo $SHELL command might output “/bin/bash“, indicating that the default shell is Bash. Similarly, the ps command might output “bash”, suggesting that the current shell is Bash.

It’s important to understand how to interpret these outputs to accurately determine your current shell. If you’re unsure about the meaning of an output, you can always refer to the man pages (manual pages) for the respective command. These pages provide detailed information about the command and its output.

Advanced Tips

Beyond knowing which shell you are using, you might also want to check the version of your shell. This can be done by appending --version to the shell command, like bash --version.

It’s also crucial to understand the difference between the default shell and the currently running shell. The default shell is the one assigned to your user account and is typically the one that starts when you open a terminal. However, you can run different shells within your terminal sessions, and these become your current shells for those sessions.

If you wish to change your default shell, you can use the chsh (change shell) command followed by the path to the new shell. For instance, to change your default shell to Zsh, you would use the following command:

chsh -s /bin/zsh

Remember to log out and log back in for the changes to take effect.


Knowing which shell you are using in Linux is essential, especially when running scripts or executing commands that are shell-specific. While there are several methods to check your current shell, their reliability may vary. Therefore, understanding these methods and their limitations can help you accurately determine your current shell in Linux. With this knowledge, you can fully leverage the power of the Linux shell, enhancing your productivity and efficiency in the Linux environment.


r00t is a seasoned Linux system administrator with a wealth of experience in the field. Known for his contributions to, r00t has authored numerous tutorials and guides, helping users navigate the complexities of Linux systems. His expertise spans across various Linux distributions, including Ubuntu, CentOS, and Debian. r00t's work is characterized by his ability to simplify complex concepts, making Linux more accessible to users of all skill levels. His dedication to the Linux community and his commitment to sharing knowledge makes him a respected figure in the field.
Back to top button