What Shell Am I Using?

Sep 25, 2009 - 2 Comments

Ever wondered what shell you are using? It’s not unusual to want or need to know, and I’ve gotten this question multiple times, but the answer could be different for everyone. The easiest way to find out what shell you are using type the following command at the command line prompt:

echo $SHELL

Yes, that is $SHELL in all caps, case matters in the unix world. You should see something like this:

$ echo $SHELL
/bin/bash

This would mean the shell is bash, but you may wind up seeing something differently, like /bin/tcsh /bin/zsh /bin/ksh or a variety of other shells that are out there.

This command works across all unix platforms, whether it’s Mac OS X, Linux, FreeBSD, or whatever, and it’s always reported back the same.

For the vast majority of Mac OS X users, you will be using the Bash shell by default, which is both the standard in all recent versions of OS X and also one of the easier to use shells out there. You can set it to another shell you want rather easily by changing the preferences inside the Mac Terminal, or by using “export $SHELL=” and adjusting it the old fashioned way.

Remember, shells can also be launched from other shells, creating a nest of sorts. For example, you can run tcsh over bash over ksh, though there isn’t much reason to do that.

Enjoy this tip? Subscribe to the OSXDaily newsletter to get more of our great Apple tips, tricks, and important news delivered to your inbox! Enter your email address below:

Related articles:

Posted by: David Mendez in Ask OS X Daily, Command Line

2 Comments

» Comments RSS Feed

  1. Matteo Corti says:

    Hi,

    this is not always true and you should not rely on it. From the bash man page:

    SHELL The full pathname to the shell is kept in this environment variable.
    If it is not set when the shell starts, bash assigns to it the full
    pathname of the current user’s login shell.

    This means that if it is already set a new shell will not replace the value on startup.

    tcsh and ksh behave the same way:

    $ echo $SHELL
    /bin/bash
    $ tcsh
    % echo $SHELL
    /bin/bash
    % ksh
    > echo $SHELL
    /bin/bash

    Matteo

  2. DistortedLoop says:

    Strangely enough, when I open a terminal window in OS X, it says “Terminal – bash – 80×24″ right along the title bar.

    I don’t recall if I set those items in the past, so perhaps they are the OS X default, but they are controlled in Terminal by opening the Preferences and clicking on Window. Here you can title the window bar with your own text, and then there are check boxes for various other things like the active process (your shell name if idle).

Leave a Reply

 

Shop for Apple & Mac Deals on Amazon.com

Subscribe to OSXDaily

Subscribe to RSS Subscribe to Twitter Feed Follow on Facebook Subscribe to eMail Updates