Linux Commands

What is the Linux command to find out which shell you are using

In the Linux operating system, the shell is the medium between the user and the computer system which communicates the commands entered by the users in the terminal to the computer and tells it to perform the specified task. There are different types of shells, the first type of shell used in about 1976 was Bourne Shell (sh) and nowadays most Linux-based operating systems are using the GNU Bourne-Again Shell, commonly known as bash.

When we use any distribution of Linux, the first thing we want to know about the shell we are using, to find out information about the shell, different commands can be used, in this write-up, we will discuss those commands.

What are the commands to find out shells you are using in Linux

There are different types of shells installed when we login the Linux operating system, to list down all these shells, we use the command:

$ cat /etc/shells

In the above output, we can see that the Bourne Shell (sh), the GNU Bourne-Again Shell (bash), and the Debian Almquist (dash) shell are installed in Linux. These shells have their own features and specifications but to know which shell is being used by our Linux, there are many commands, the first one which we are going to discuss is simply printing the value of variable $SHELL with the help of echo command:

$ echo $SHELL

The output shows that we are using the bash shell. Another way of finding shell is using the echo command:

$ echo $0

Likewise, the shell can be found out by using the ps command, though the ps command is used to display the PIDs of all the running processes:

$ ps

To specifically find the shell you are using with the help of the ps command, execute the following command with the flag “-p” which is for PID, and pass $$, to use the current PID of the shell:

$ ps -p $$

The column under the name of “CMD” is displaying the shell name which you are using, likewise, the readlink command can also be used to display the shell:

$ readlink /proc/$$/exe

One of the most used technique to find the shells is by accessing the /etc/passwd, it contains the important credentials likes usernames, passwords, and users, so we can use this path with the help of the grep command and display the shell you are using:

$ grep "^$USER" /etc/passwd

We used the grep command to display the details of variable $USER stored on the /etc/passwd, and the last command we are going to discuss in this write-up is the lsof command, it is used to list the open files and processes, but it can also be used to display the shell by using the flag “-p” with $$:

$ lsof -p $$


Shell plays an important role; it communicates the information given by the user to the computer and makes sure the user-specified tasks should be completed by the computer. In this write-up, we have discussed different commands through which we can find out the name of the shell we are using in Linux. There are different methods discussed in this write-up, all are convenient and most helpful.

About the author

Hammad Zahid

I'm an Engineering graduate and my passion for IT has brought me to Linux. Now here I'm learning and sharing my knowledge with the world.