Which shell am I running on?
$SHELL
is not necessarily your current shell, it is the default login shell. To check the shell you are using, try
ps $$
This should work on most recent Unix/Linux with a ps
that supports the BSD syntax. Otherwise, this is the portable (POSIX) way
ps -p $$
That should return something like this if you are running tcsh
:
8773 pts/10 00:00:00 tcsh
If you want to have tcsh
be your default shell, use chsh
to set it.
From the command line, you can also use the $0
variable to determine which shell you are using. e.g.:
~$ echo $0
/bin/bash
~$ ksh
$ echo $0
ksh
Note: you cannot determine the shell using $0 within a script, because $0 will be the script itself.
This is an amendment to all of the better answers above. I had a tiny issue identifying dash at one point; seemed right to share:
curl -fsSL http://www.in-ulm.de/~mascheck/various/whatshell/whatshell.sh | sh
ash (dash 0.5.5.1 ff)
curl -fsSL http://www.in-ulm.de/~mascheck/various/whatshell/whatshell.sh | bash
bash 4.3.30(1)-release
Good for troubleshooting in tight spots is all. Cheers.