如何在Linux中获取Shell类型和版本?

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. $SHELLenvironment 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命令

Using Ps Command
Using Ps Command
使用Ps命令
LEARN MORE  Useful Linux Commands
了解更多有用Linux命令

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值