1

I have a Red Hat Linux machine and I'm trying to find out what shell I am using.

When I run echo $0, I get sh. ps -p $$ has the same output.

However, as I understand from [here][1], sh is not a real shell, but only a symlink to a real shell such as bash, dash, ksh, etc.

So how can I find out the real shell behind sh?

o1ctav
  • 111
  • 2
  • 10
  • 1
    Possible duplicate of [How to see full symlink path](http://stackoverflow.com/questions/16017500/how-to-see-full-symlink-path) – Aserre Mar 08 '17 at 11:47
  • 4
    Indeed, `/bin/sh` is a simple symlink. Use the command from the question I marked as duplicate to see to which shell it links to. On my wsl, `readlink -f /bin/sh` returns `/bin/dash` – Aserre Mar 08 '17 at 11:48
  • The point of `/bin/sh` is that you shouldn't *care* which shell it is. You write code that is defined by the POSIX specification, and whatever shell happens to be `/bin/sh` will execute it properly. Knowing which shell it is will just tempt you to use features specific to that shell, which defeats the purpose of using `/bin/sh` in the first place. – chepner Mar 08 '17 at 13:31

1 Answers1

0
echo "$SHELL"

$SHELL is the shell for the current user but not necessarily the shell that is running at the moment.

Another way - is to use the ps command with -p {pid}

ps -p <PID>

Result has the CMD column where that specific process is running

  PID TTY          TIME CMD
  100 ?        00:00:00 bash
nemesis
  • 150
  • 9