linux,

Which shell am I using - how to check

Nov 21, 2021 · 1 min read · Post a comment
Which shell am I using - how to check

Linux comes with support for multiple flavors of shell, including bash, zsh, ksh, csh, and so on. 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 the default shell:

$ echo $SHELL

Example output:

/bin/zsh

Find the current shell you are working on:

$ echo $0

Example output:

-zsh

Or, alternatively:

$ ps -p $$

Example output:

PID  TTY           TIME  CMD
2167 ttys001    0:00.30  -zsh

List currently installed shells:

$ cat /etc/shells

Example 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.