Linux comes with support for multiple flavors of shell, including bash, zsh, ksh, csh, or suchlike. This time I’ll be focusing on how to find out which shell you are using, which is the default one and list of all installed shells.
Prerequisites
- Shell environment
Solution
Find default shell.
echo $SHELL
Output:
/bin/zsh
Find the current shell you are working on.
echo $0
Output:
-zsh
Or, alternatively:
ps -p $$
Output:
PID TTY TIME CMD
2167 ttys001 0:00.30 -zsh
List currently installed shells.
cat /etc/shells
Output:
/bin/csh
/bin/dash
/bin/ksh
/bin/sh
/bin/tcsh
/bin/zsh
/usr/local/bin/pwsh-preview
/usr/local/bin/pwsh
Conclusion
As always, hope this was super handy and if you can think of any other methods to list the current or the default shell environment, please let me know. Feel free to leave a comment below and if you find this tutorial useful, follow our official channel on Telegram.