0

On some the shell can be read on in the command prompt, other can be seen when help is ran. But this are not covered by all the shells.

Is there a general command to see what shell is running?

2 Answers2

4

This should work with most shells and most OSes:

$ ps -o comm -p $$ | tail -n -1
ksh93

Edit: after reading the duplicate link, here is a simpler way that avoids the tail command.

$ ps -o comm= -p $$
ksh93 
jlliagre
  • 61,204
  • @jillagre Strange, the standard allows (and mentions) both syntaxes. So -n -1 and -n 1 are equivalent, while -n +1 is not. Bizarre. – l0b0 May 15 '13 at 13:40
  • I guess that's for historical reasons. Pre-standard tail didn't implemented the -n option, that was tail -1 for the last line and tail +1 for the first one. They kept the same syntax when -n was added not to break habits/usage. Not specifying a sign shouldn't but mean the last line(s), as the - in tail -1 was more to introduce an option than a sign indicator. – jlliagre May 15 '13 at 13:57
1

You can see in /etc/passwd file, or type:

echo $SHELL

or

env

to see your default shell.

cuonglm
  • 153,898
  • Looking in /etc/passwd assumes that the user account exists in /etc/passwd, which may not be the case (for example in the case of such information being stored in LDAP, AD or other remote repositories). – user May 15 '13 at 13:07