开发者

How can I tell which Unix shell I am using? [duplicate]

开发者 https://www.devze.com 2023-01-08 22:58 出处:网络
This question already has answers here: How to determine the current interactive shell that I'm in (command-line)
This question already has answers here: How to determine the current interactive shell that I'm in (command-line) (开发者_如何学运维28 answers) Closed 8 years ago.

Is there an easy way by which I can tell which type of Unix shell I am in?

A command that shows whether I am in a Bash, C shell, KornShell (ksh), tcsh, or Z shell (zsh)?

E.g.,

whatshellisthis


Try:

echo $0

This often works across a range of shells.


Mac

ps

  PID TTY           TIME CMD
  223 ttys000    0:00.33 -bash

OpenBSD

ps

  PID TT  STAT       TIME COMMAND
20038 p0  Ss      0:00.01 -ksh (ksh)
22251 p0  R+      0:00.00 ps

Or just echo $SHELL.


The echo $SHELL command will give you your shell name relative to root.


Every shell I know of sets the $ variable ($$) to its pid. So...

ps | grep $$


If you are using the OS X terminal, then the shell is specified in the Terminal's title bar when you launch it - like so: Terminal - ShellName - 80x24

0

精彩评论

暂无评论...
验证码 换一张
取 消