Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to query the version and type of shell currently used under the Linux command line

2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "how to query the current version and type of shell under the Linux command line", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let the editor take you to learn "how to query the version and type of shell currently used under the Linux command line"!

There are several ways to see what shell you are currently using, and the easiest way is by using the special parameters of shell.

For one thing, a special parameter named "$$" indicates the PID of the shell instance you are currently running. This parameter is read-only and cannot be modified. So, the following command will also display the name of the shell you are running:

The code is as follows:

$ps-p $$

PID TTY TIME CMD

21666 pts/4 00:00:00 bash

The above command works in all available shell.

If you are not using csh, another way to find the currently used shell is to use the special parameter "$0", which indicates the name of the currently running shell or shell script. This is a special parameter for Bash, but can also be used in other shell, such as sh, zsh, tcsh, or dash. Use the echo command to see the name of the shell you are currently using.

The code is as follows:

$echo $0

Bash

Don't be fooled by a separate environment variable called $SHELL, which is set to the full path of your default shell. Therefore, this variable does not necessarily point to the shell you are currently using. For example, even if you call a different shell,$SHELL in the terminal, it remains the same.

The code is as follows:

$echo $SHELL

/ bin/shell

So, to find out the current shell, you should use $$or $0, but not $SHELL.

Find out the current version of Shell

Once you know which shell you are using, you may want to know the version of this shell. To do this, type shell on the command line followed by the "--version" parameter to view the version information. For example:

For bash shell:

The code is as follows:

$bash-version

GNU bash, version 4.3.30 (1)-release (x86_64-pc-linux-gnu)

Copyright (C) 2013 Free Software Foundation, Inc.

License GPLv3+: GNU GPL version 3 or later

This is free software; you are free to change and redistribute it.

There is NO WARRANTY, to the extent permitted by law.

For zsh shell:

$zsh-version

Zsh 5.0.7 (x86_64-pc-linux-gnu)

For tcsh shell: $tcsh-- version

The code is as follows:

Tcsh 6.18.01 (Astron) 2012-02-14 (x86_64-unknown-linux) options wide,nls,dl,al,kan,rh,nd,color,filec

For some shell, you can also use shell-specific variables (for example, $BASHVERSION or $ZSHVERSION).

The code is as follows:

$echo $BASH_VERSION

4.3.8 (1)-release

At this point, I believe you have a deeper understanding of "how to query the version and type of shell currently used under the Linux command line". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report