bash: Find Out the Version of Your Unix Shell

bash (Bourne Again SHell) comes with pretty much every Unix-like OS these days. If you ever wonder what exact version of bash shell you have on your system, here's how you find out: just use the –version parameter in the command line.

Using /bin/bash to tell its version

On RedHat Linux, this is how it might look:

bash-2.05b$ /bin/bash --version
GNU bash, version 2.05b.0(1)-release (i386-redhat-linux-gnu)
Copyright (C) 2002 Free Software Foundation, Inc.

On Solaris 10 (one of the latest OpenSolaris builds, actually), it's a very similar output as well:

-bash-3.2$ /bin/bash --version
GNU bash, version 3.2.25(1)-release (i386-pc-solaris2.11)
Copyright (C) 2005 Free Software Foundation, Inc.

If you don't know the location of bash binary

The first and most obvious thing is to use which command to confirm the possible location of your bash binary.

On Linux:

 bash-2.05b$ which bash

In Solaris:

-bash-3.2$ which bash

As you can see, this command returns you the full path to a binary, bash in our case. Once you know the full binary name, run it like explained in the first part of this post to confirm the version. Bear in mind that which command does not always return a result.

If this didn't work, a more sophisticated way to confirm the version of bash on your RedHat Linux system is to use rpm:

bash-2.05b$ rpm -qa | grep bash

This commands queries the RPM database of your RedHat Linux and confirms which version of the bash RPM package is installed, which naturally matches the version of the bash itself.

  • It is quite possible to have multiple bash binaries, say if you've installed bash4, via homebrew on OSX.

    In such instances echo "$BASH_VERSION" will give you the current bash version of the current shell (assuming it is a bash shell)