How to Check Which Shell I am Using?

In Linux, the “shell” acts as an interface/medium between the user and the system kernel. It takes input from the user, executes it, and displays the output. Linux supports 4 types of shells such as “Bourne”, “Korn”, “C”, and “Bourne again (bash)” shells. 

This post lists all possible methods to check which shell I am using with the following guidelines:

Method 1: Use “echo” Command

The “echo” pre-installed command utility is used for showing the test or strings that are passed as an option/argument in the terminal. It is generally used in shell scripts.

It can also print the environment variables value that is assigned by default. In this method, we get the “$SHELL” variable value to check the current using shell:

$ echo $SHELL

The shell I am using in the current Linux system is “bash”.

Alternative: The user can also pass the “$0” to the “echo” command. The “$0” invokes the shell name or the script:

$ echo $0

Method 2: Use “ps” Command

Another built-in command line tool to check the shell is “ps(Process State)”. It is beneficial to view the currently running processes’ status that is in running state along with their PIDs.

The “ps” command without any argument or option prints out the name of the current working shell  including some other details like this:

$ ps

The first line of the output displays currently using shell “bash”.


To show only the shell without the background process “ps” use the below-mentioned command:

$ ps -p $$

Method 3: Use the “lsof” Command 

The “lsof” stands for “list open files” utility that shows the active process in a file system. It comes by default in all Linux distributions.

It offers a “-p” flag to filter out the open files of the shell that I am using along with other additional information:

$ lsof -p $$

 The first column “Command” shows the shell “bash”.

Method 4: Use the “readlink” Command

The readlink command is generally used to print the symbolic link paths or print the file name. Here in this method, it is utilized to print out the location of the current shell followed by “proc(process information)”, “$$(Process id of shell)”, and “exe”:

$ readlink /proc/$$/exe

The exact path of the “bash” shell is displayed on the terminal.

Method 5: Use the “/etc/passwd” File

In Linux, the “/etc/passwd” files contain the user account essential information including “name”, “user ID”, “home directory”, “password”, “shell”, and so on. The local user can just read this file for checking the shells via the “cat” command:

$ cat /etc/shells

The output displays all valid login shells of the system.

Use the “$USER” variable to the “grep” command to filter out the current user shell on the terminal:

$ grep "$USER" /etc/passwd

The last field of the “/etc/passwd” file shows the shell that login user “itslinuxfoss” is using.


In Linux, “echo”, “ps(process state)”, “lsof(list of open files)”, and “readlink” command line tools are utilized to check the shell. In addition, the “/etc/passwd” file also provides the valid login shells and the specified login user shells via the “grep” command. All of the commands are easily executed without generating an error. This post has described all possible ways to check which shell I am using in Linux.