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.

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.

Here are three sample outputs:

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….

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.