How to find out which shell is in use in Linux
March 15, 2021
There are several Linux shells, each with its own characteristics. Examples of popular shells are Bash (which is the default shell on many distributions) and ZSH (which is the default shell on Kali Linux, it has many fans).
The shell information is contained in the $SHELL environment variable to see its value and to find out which shell is in use, run the command:
See what exactly will be displayed:
- /bin/bash - means you have Bash
- /usr/bin/zsh - means you have ZSH
How to find out which Linux shell is actually being used
But is it really that simple with shells?
Take a look at the following screenshot and try to guess which shell will handle subsequent commands?
The screenshot clearly shows that the command printed “/usr/bin/zsh”, so we can say that it is using the ZSH shell.
But this is the wrong answer.
Yes, the default shell on this system is ZSH, but just above the command is
and even though the decoration or the command line prompt hasn't changed, Bash now handles the commands you enter.
This is easy to prove if you run the command
then Bash will show you a quick reference for its commands. And ZSH will display a message that the command was not found:
What does the $SHELL variable actually show? Apparently, this is just the default shell on this system, without taking into account the fact that the user could start another shell. However, outputting the value of the $SHELL variable will in most cases answer the question of which shell is being used on that system.
To verify that you are using Bash, you can run the command:
Another way to “reveal” Bash is to look at how the Ctrl+x Ctrl+v keystrokes respond. In response, Bash will print a line similar to the following:
GNU bash, версия 5.1.4(1)-release (x86_64-pc-linux-gnu)
- How to change the login shell in Linux. chsh instruction (100%)
- How to convert a string to uppercase in Bash (71.2%)
- How to convert a string to lowercase in Bash (71.2%)
- How to disable “did you mean...” feature in Linux shell (71.2%)
- How to run small Python code in Bash (59.6%)
- What is the difference between “systemctl reboot” and “reboot” and “systemctl poweroff” and “poweroff” (RANDOM - 50%)