In this quick and simple post I will show you how to find out which shell you are running, list all installed shells, and change shells in Linux. You can either do this temporarily by creating a subshell which will only last until you exit that session or you can permanently set a different shell to your default for all future sessions.
Find Out Current Running Shell
If you are unsure of which shell you are currently running then you can find out by running the following commands.
echo $SHELL # This will tell you which shell you are running
bash --version # If you are running bash this will tell you the version
List All Installed Shells
If you want to see which shells you have available/installed on your system then you can find a list by checking in /etc/shells. You can also search for specific ones if need be using grep.
grep shellname /etc/shells
Temporarily Change Shells
To temporarily change shells all you need to do is spawn a subshell. You can do this by using one of the following examples, although if you want to use a different shell then you will need to change the command to match your desired shell. Here are some examples of temporarily switching to a few of the more popular shells.
/bin/ksh # Use KSH shell (if installed)
/bin/bash # Use BASH shell
/bin/zsh # Use ZSH shell (if installed)
/bin/fish # Use Fish shell (if installed)
You can switch back to your default shell by running the command “exit” to end your subshell.
Permanently Change Shells
You can permanently change your shells by using the chsh command. This command will prompt you for your password and then set your desired shell as your default login shell.
chsh -s /bin/zsh # Replace zsh with whatever shell you like
You can verify that your changes took by running the following command and changing the grep search string to your username (in this example I will use root).
grep root /etc/passwd
I hope this tutorial has helped you, more posts are always on the way! Please don’t forget to like, comment, or share!