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:
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:
The output shows that we are using the bash shell. Another way of finding shell is using the echo command:
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:
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:
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:
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:
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 $$:
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.