How do I check my bash version?

last updated in Categories , , , , , , ,

How do I check my bash shell version running on a Linux or Unix like operating systems? Many bash tutorial says that you need bash version 4.x or above. How do I find the version of bash I am running on macOS desktop or Ubuntu Linux server?

Introduction – Knowing bash version can help to see if the specific feature will work with your system or not. This page shows how to check or find out your bash shell version running on a *BSD, Linux, macOS, and Unix-like operating systems.

How do I find the version of bash I am running?

To find my bash version, run any one of the following command:

  1. Get the version of bash I am running, type: echo "${BASH_VERSION}"
  2. Check my bash version on Linux by running: bash --version
  3. To display bash shell version press Ctrl+x Ctrl+v

Check my bash version using ${BASH_VERSION} shell variable

Type echo command or printf command:

echo "BASH_VERSION"
printf "%s\n" $BASH_VERSION

Find bash shell version using the --version option

Just pass the --version to the bash command to show version information for this instance of bash shell on the screen and exit successfully:

bash --version
echo $?
How do I find the version of bash I am running on Linux or Unix or macOS
How to check Bash version

Display version information about the current instance of bash using keyboard shortcut

Just press CTRL + x followed by CTRL + v and you should see something as follows on screen:

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

Use package manger to find out bash version

Use the dnf command on a Fedora Linux and yum command on a CentOS/RHEL to get version info about bash package:
$ yum info bash

How to check bash version on Linux
How to check bash version on a CentOS Linux using yum command

How to check Bash version on Debian or Ubuntu Linux

Debian/Ubuntu Linux user try the apt command or apt-cache command or dpkg command as follows:
$ apt info bash
OR
$ apt-cache show bash

How to get bash version number on Unix or Linux
How to get bash version number using a package manager

Conclusion

This page showed you various commands on how to check bash version on your Linux or Unix-like operating system.

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

Start the discussion at www.nixcraft.com

Historical Comment Archive

6 comment

    1. That is stupid. The -v prints shell input lines as they are read. Use the --version:
      bash --version

  1. I am using:

    #!/bin/bash
    echo "My Bash shell version is $BASH_VERSION"

    It might help someone.

    Still, have a question? Get help on our forum!