I would like to know about my shell version using a Linux command. I tried the following command, but it shows the type of the shell I am in.
Command:
echo $SHELL
Result:
/bin/bash
I would like to know about my shell version using a Linux command. I tried the following command, but it shows the type of the shell I am in.
Command:
echo $SHELL
Result:
/bin/bash
It depends on whether you want to know the version of your default login shell, or the version of the shell you're currently running. They're not necessarily the same.
For your default login shell, as the accepted answer says,
$SHELL --version
is likely to work. Most (but not all) shells accept a--version
option. (dash
does not.) And this assumes that the value of$SHELL
hasn't been changed (there can be valid reasons to do so).For the shell you're currently running, if it happens to be
bash
you can type:For
tcsh
:For
zsh
:For
ksh
:For
fish
:Again, this assumes that the relevant variable hasn't been modified (there's rarely any non-malicious reason to change it).
Bash in particular has an array variable
$BASH_VERSINFO
that gives more information in a form that's easier to process programmatically. Printing$BASH_VERSINFO
only prints the first element; to print all elements:There is a case when your shell does not have a command line parameter to determine the version directly. This case is Bourne shell. For Bourne shell I would recommend to use a script: https://www.in-ulm.de/~mascheck/various/whatshell/whatshell.sh. The script is pretty small so that it is not a big trouble to review it and understand how it is working. I have tested this script inside different shells on Linux and Solaris and it always gave the shell version for me.
Some examples:
Ubuntu 18.04
CentOS 4
Solaris 10
AIX 6.1
This is also answers for the question Bourne shell version which was marked as off topic.
This will do it:
In my case, the output is: