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
If you don't specify a program in the shebang line, I believe /bin/sh will be used. Unfortunately, I don't believe there is a good portable way to determine what that shell is.
If you're on e.g., Linux, you can find out the executable path through /proc
:
$ readlink "/proc/$$/exe"
/bin/dash
and getting the executable name is easy through ps $$
.
But that won't help you with the type of shell (except via a lookup table of known shells) nor with the version (AFAICT, there isn't even a way to get the version from dash)
You can use the following in Arch Linux.
echo $SHELL
I want something that has the same feel of
uname
,pwd
,whoami
. Just a plain utility with a simple output.
So apparently the conclusion is that the tool I want does not exist, and there's no simple cross-platform way to go about this.
Some answers here work fine on Linux.
Try ($$ is shell variable set to process id of the shell):
ps -ef | grep $$
or try this (/proc/self is aloso process id of the shell):
ps -ef | grep /proc/self
As regards to "-bash" - dash means it's login shell. Type bash again and now you'll see that the shell is just "bash" (without dash)
Rather than trying to determine the shell currently being used, it is typically more appropriate to simply re-exec as the desired shell. This may be nothing more than an historical workaround of the fact that there is no reliable, portable way to determine the shell you are currently using. The best thing to do is to write your script to work in as many shells as possible so that it's not an issue. (eg, portability matters, no matter how many people want to claim that "bash is everywhere")
I think 'finger' is the right one you are looking for. Try this command:
finger `whoami`