0

This question already has an answer here:

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?

marked as duplicate by Stéphane Chazelas, Thor, manatwork, Chris Down, slm May 15 '13 at 16:33

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • @StephaneChazelas You are right default is ambiguos I edited – Eduard Florinescu May 15 '13 at 12:41
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 
  • @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.

  • 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). – a CVn May 15 '13 at 13:07

Not the answer you're looking for? Browse other questions tagged or ask your own question.