What Is The Linux Command To Find Out Which Shell You Are Using
Maybe your like
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 $$
Conclusion
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.
Tag » What Shell Am I Using
-
How Do I Find Out What Shell I Am Using On Linux/Unix? - NixCraft
-
How Do I Check Which Shell I Am Using? - Ask Ubuntu
-
Which Shell Am I Using? How Can I Switch? - Moncef Belyamani
-
Different Ways To Check Which Shell You Are Using On Linux
-
Determine The Current Shell In Linux - Baeldung
-
How To Find Which Shell I Am Using On Linux - Xmodulo
-
How To Determine The Current Interactive Shell That I'm In (command ...
-
What Shell Am I Using? Here's How To Find Out - OSXDaily
-
How To Find Which Shell Am I Using In Linux [4 Methods]
-
4 Ways To Check Which Shell You Are Using On Linux - LinuxOPsys
-
Bash - Which Shell Am I Running On? - Unix & Linux Stack Exchange
-
How To Tell What Shell Your Mac Is Using - Macinstruct
-
Which Shell Am I Using? - ImagineLinux
-
How Do I Know If I Have Bash Or Zsh? - Linux Hint