Display my actual used shell

Here a short blog post… if you work in several companies or with different accounts, it’s useful to know, which shell you’re currently using (not the default shell from /etc/passwd). Of course, you can simply change the shell and choose your favorite one, but if you just want to know the actual shell, you can run one of the following two commands.

The special variable $0 contains the name of the running “script” itself. The brackets {} are optional, but I recommend to always set them in shell scripts.

echo ${0}    # recommendation in shell scripts.
echo $0      # short version.
# recommendation in shell scripts. echo $0 # short version.
">bash ksh sh

In the special variable $$ is the process id of the parent process of your session saved. And with the command ps -p informations about the process is printed out. Here again, the brackets are optional.

ps -p ${$}    # recommendation in shell scripts.
ps -p $$      # short version.

Here are three sample outputs:

15912 pts/2 00:00:00 sh
15886 pts/3 00:00:00 ksh
15574 pts/1 00:00:00 bash

On this page or the bash man page are more special variables listed, which can be useful for scripting.
Stay tuned, soon we’re launching a scripting guideline series on this blog and there, we’ll describe the brackets in detail….


  • solitaire spider

    I can’t even imagine the self control required to work at a bubble wrap factory.

  • celeb networth

    Thank you so much! I hope to hear more updates from you, this helps me a lot.

  • Tucson

    Hi Pascal, this is very informative. I have always struggled to do this but now I can easily display my used shell. Thanks

  • doula

    It’s good! Thank you very much!