How can I tell which Unix shell I am using?

LinuxShellUnix

Linux Problem Overview


Is there an easy way by which I can tell which type of Unix shell I am in?

A command that shows whether I am in a Bash, C shell, KornShell (ksh), tcsh, or Z shell (zsh)?

E.g.,

whatshellisthis

Linux Solutions


Solution 1 - Linux

Try:

echo $0

This often works across a range of shells.

Solution 2 - Linux

Mac
ps

  PID TTY           TIME CMD
  223 ttys000    0:00.33 -bash
OpenBSD
ps

  PID TT  STAT       TIME COMMAND
20038 p0  Ss      0:00.01 -ksh (ksh)
22251 p0  R+      0:00.00 ps

Or just echo $SHELL.

Solution 3 - Linux

The echo $SHELL command will give you your shell name relative to root.

Solution 4 - Linux

Every shell I know of sets the $ variable ($$) to its pid. So...

ps | grep $$

Solution 5 - Linux

If you are using the OS X terminal, then the shell is specified in the Terminal's title bar when you launch it - like so: Terminal - ShellName - 80x24

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionRHTView Question on Stackoverflow
Solution 1 - LinuxgggView Answer on Stackoverflow
Solution 2 - LinuxNikolai FetissovView Answer on Stackoverflow
Solution 3 - Linuxa.saurabhView Answer on Stackoverflow
Solution 4 - LinuxpraView Answer on Stackoverflow
Solution 5 - LinuxAlexView Answer on Stackoverflow