While using remote sessions we may need to know the type and version of the remote shell. Bash is popular but there may be different shells like sh, csh, ksh etc.
在使用远程会话时,我们可能需要了解远程Shell的类型和版本。 Bash很流行,但可能会有不同的shell,例如sh,csh,ksh等。
使用$ SHELL变量 (Using $SHELL Variable)
Shells provide environment variables to give information about the shell and the environment. $SHELL
environment variable can be used to get current she type. $SHELL variable information is not so reliable.
Shell提供环境变量以提供有关Shell和环境的信息。 $SHELL
环境变量可用于获取当前的她类型。 $ SHELL变量信息不是那么可靠。
$ echo $SHELL
/bin/bash
We can see that our current shell is bash
我们可以看到我们当前的shell是bash
使用ps命令 (Using ps Command)
We can use ps command with some parameters to get shell information like below.
我们可以使用带有某些参数的ps命令来获取shell信息,如下所示。
$ ps -p $$
PID TTY TIME CMD
3380 pts/8 00:00:00 bash
We use ps command by providing the current process
我们通过提供当前进程来使用ps命令

翻译自: https://www.poftut.com/how-to-get-shell-type-and-version-in-linux/