Linux 如何判断我使用的是哪个 unix shell?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3349370/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-03 20:18:43  来源:igfitidea点击:

How to tell which unix shell I am using?

linuxshellunix

提问by RHT

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

有没有一种简单的方法可以让我知道我使用的是哪种类型的 unix shell?

A command that shows whether I am in a bash/ csh/ ksh/ tcsh/ zsh?

无论我是在一个,显示了命令bash/ csh/ ksh/ tcsh/ zsh

i.e.

IE

whatshellisthis

whatshellisthis

采纳答案by ggg

Try:

尝试:

echo 
mac:~$ ps
  PID TTY           TIME CMD
  223 ttys000    0:00.33 -bash

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

This often works across a range of shells.

这通常适用于一系列 shell。

回答by Nikolai Fetissov

ps | grep $$

Or just echo $SHELL

要不就 echo $SHELL

回答by pra

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

我知道的每个 shell 都将 $ 变量 ($$) 设置为它的 pid。所以...

##代码##

回答by Alex

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

如果您使用的是 OSx 终端,则在您启动它时会在终端的标题栏中指定 shell - 如下所示: Terminal - ShellName - 80x24

回答by a.saurabh

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

echo $SHELL命令将为您提供相对于 root 的 shell 名称。