Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What shell am I in?

Tags:

shell

unix

Is there a command to identify the name/type of current shell, the path to the shell binary, and the version of the shell?

I don't need all of that, but the more I can get, the better.

I want something that has the same feel of uname, pwd, whoami. Just a plain utility with a simple output. (which so far hasn't showed up :/ )

re ps

$ ps -o comm $$ COMM -bash 

Why -bash instead of the full path as it would be with everything else? What's the deal with the dash there?

like image 413
kch Avatar asked Aug 15 '09 09:08

kch


People also ask

How do I know if Im using bash or zsh?

Now, coming to the article's main subject, how will you know that you have bash or zsh? The answer is quite simple. Use the “–version” command to confirm the existence of both shells on your Linux system.

What is shell name?

The origin of the Shell name can be traced back to the seashells that Marcus Samuel senior imported from the Far East during the late 19th Century. When his sons Marcus junior and Samuel were looking for a name for the kerosene that they were exporting to Asia, they chose Shell.


1 Answers

The command or path to the currently running shell is stored in the environment variable $0. To see its value, use:

echo $0 

This outputs either your currently running shell or the path to your currently running shell, depending on how it was invoked. Some processing might be required:

prompt:~$ echo $0 /bin/bash prompt:~$ sh sh-4.0$ echo $0 sh sh-4.0$ exit exit prompt:~$ /bin/sh sh-4.0$ echo $0 /bin/sh sh-4.0$ 

The $SHELL environment variable contains the user's preferred shell, not necessarily the currently running shell.

like image 93
Mala Avatar answered Oct 01 '22 13:10

Mala