What shell are you using?


We want to find out which shell we are using


We are in a new operating system or we are performing tests with different types of shells and we want to know which one is being used at the moment

How to

There are different ways to detect about our shell. For instance:

echo $SHELL

will print the environment variable that points to our shell. It may print, for instance:


We may also have the same type of result by consulting our full environment:

env | grep -i shell

With the previous statement, we print all environment variables and filter the results with grep using the -i option to ignore casing. The result may be something similar to the following:


We may also consult the path to /bin/sh which, usually, is a symbolic link to the shell being used, as follows:

ls -la /bin/sh

Which may result in a symbolic link which means that we are really using bash as the default shell:

lrwxrwxrwx 1 root root 4 Dec 10 01:15 /bin/sh -> bash*

But none of the previous options necessarily print our current shell. They simply print what is permanent or default, i.e., any time we go into a shell, bash will be our shell type.

We may also print our shell with the following command which, opposite to the previous examples, will be accurate in terms of out currently used shell:

echo $0

which will print the name of our shell (if you want to check that the result will be accurate, simply run the following statement before the echo $0</code: exec /bin/csh, for instance)


Finally, there is also a way to find out, in the current list of processes, through the use of ps, filtering the results with awk, what is the current shell (the option passed in to awk will only print the fifth field in last line of the statement ps):

ps $$ | tail -1 | awk '{print $5}'

And once again, the result would be something similar to;



All the previous statements resulted in the same result for my operating system, as supposed. However, some of them do not necessarily print the currently using shell. It may print only our default shell. Knowing in which situations we may use which is important

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s