How to check the version of Shell that Linux system is using?

  

Multiple shells can be opened at the same time in Linux, but there can only be one running shell. So how do I check if the Linux system is using the Shell version? Let me introduce it below.

Shell find the version you are currently using

There are several ways to view what you currently use shell, the easiest way is through Shell by using special parameters of the shell.

First, a special parameter called “$$” 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:

1.$ ps-p $$

2.PID TTY TIME CMD

3.21666 pts /400:00:00bash

The above command works in all available shells.

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

1.$ echo $0

2.bash

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

1. $ echo $ SHELL

2./bin/shell

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

Finding the current shell version

Once you know which shell you are using, you may want to know the version of this shell. To do this, enter the shell on the command line and add the “--version” parameter to see the version information. For example:

For bash shell :

1.$ bash--version

2.GNU bash, version 4.3.30(1)-release (x86_64-pc- Linux-gnu)

3.Copyright(C)2013FreeSoftwareFoundation, Inc.

4.LicenseGPLv3+: GNU GPL version 3or later

5.Thisis free software; you are free To change and redistribute it.

6.Thereis NO WARRANTY, to the extent permitted by law.

For zsh shell:

1.$ zsh --version

2.zsh 5.0.7(x86_64-pc-linux-gnu)

For the tcsh shell: $ tcsh --version

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

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

1.$ echo $BASH_VERSION

2.4.3.8(1)-release

The above is a way to check if the Linux system is using the version of Shell. Is it very simple? Well, everyone can try it.

Copyright © Windows knowledge All Rights Reserved