What shell am I in?

When you connect to a system, whether directly on the system’s keyboard or through a remote connection you will automatically start in your default shell. The default shell was originally assigned to you when your account was created.

To find out what shell you are currently using we can use the echo command:

$ echo $SHELL

In this command we are using the echo command to examine the value of the environment variable $SHELL. This variable was set by the system when we started this command line session and shows the full path to the shell we were assigned at login. Here are some common shells you might see:

  • /bin/sh – Bourne shell
  • /bin/bash – Bourne Again shell
  • /bin/csh – C shell
  • /bin/ksh – Korn shell
  • /bin/tcsh – TC shell
  • /bin/zsh – Z shell

Shell binaries are also commonly found in the /usr/local/bin directory. Consult your system administrator if you’re having trouble finding your shell binaries.

Oracle Shell ScriptingFor more information like this check out my book Oracle Shell Scripting, only $34.95 from Rampant TechPress.

Buy it now!

4 thoughts on “What shell am I in?”

  1. Using $SHELL is fine if you need to find out your login shell. However, to get the true value of which shell is being used at the current moment can I recommend that you teach people to use echo $0 (although, admittedly csh will produce "No file for $0") since we may have fired up a different shell since logging in and will invariably need to check which is running before performing any specific shell-scripting?


    $ grep lee /etc/passwd
    $ echo $SHELL $0
    /bin/bash bash
    $ ksh
    $ echo $SHELL $0
    /bin/bash ksh

Leave a Reply

Your email address will not be published. Required fields are marked *