(learning bash) I was trying to check the bash version so I typed /bin/bash -v.

That outputted a whole lot of text to the screen (contents of .bashrc, and other files sourced from it).

Could I have screwed up something (like overwriting some config files/setting incorrect environment variables etc.) due to that command?

I also can't find documentation on what the -v switch is for.

  • If you ran bash -v you invoked a new bash shell with verbose mode activated, so you will see verbose output for further commands (at the very minimum you'll see printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"). To end the verbosity, type exit command - you will be back in the original non-verbose bash shell (or whatever shell you were in).
    – ADTC
    Apr 5, 2016 at 3:24
  • 1
    If you want the version of the "currently running" shell: stackoverflow.com/questions/3327013/…
    – Sohail Si
    Mar 29, 2021 at 9:13
  • How can I "link" another question here? (not just comment)
    – Sohail Si
    Mar 29, 2021 at 9:13

6 Answers 6


The -v parameter for bash stands for verbose, and instructs bash to print out as much information as possible about what it is doing. On startup, it will print out all the configuration it is reading in.

To print out the version information for bash, use bash --version.

  • Great! I also found the list of switches for bash.
    – Zabba
    May 2, 2011 at 17:21
  • 41
    Alternatively, if you're already running a bash shell, you can output the content of the special BASH_VERSION variable. echo "$BASH_VERSION". There's also a special array (BASH_VERSINFO) containing each version number in separate elements. if ((BASH_VERSINFO[0] < 4)); then echo "Sorry, you need at least bash-4.0 to run this script." >&2; exit 1; fi
    – geirha
    May 2, 2011 at 20:42
  • 3
    typo, should be something like [ "${BASH_VERSINFO}" -lt 4 ] or [ "${BASH_VERSINFO[0]}" -lt 4 ]
    – bufh
    Apr 22, 2015 at 11:51
  • 1
    The problem with this method is you cannot be 100% sure that any script, symbolic link, or any other kind of mess up configuration, who changed any environment variable at login. As I answered below, Ctrl+x Ctrl+v will show you exactly the bash version you're currently running, regardless of any environment variable.
    – vegatripy
    Jul 11, 2017 at 8:53
  • 1
    It's worth pointing out that this will tell you the version of which bash (located at /bin/bash on most systems), which may be different than the version that happens to be running in some prompt or script. (For example, a script started with #!/usr/local/bin/bash might use a different version). Other methods (documented in other answers) may also be helpful.
    – mkasberg
    Jun 6, 2018 at 21:28

When running bash (e.g. from gnome-terminal) you can check value of BASH_VERSION environment variable.


If the value is empty, you are not running bash.

  • 17
    This is better than just running bash --version, because it confirms that you are currently running bash, not just that you have bash installed on your system.
    – Flimm
    Apr 11, 2013 at 9:23
  • 2
    +1 bash --version does not show the bash you are currently using.
    – gabeio
    Mar 6, 2014 at 1:38
  • Beware: A set BASH_VERSION does not ensure that you are running bash: export BASH_VERSION; csh -c 'echo $BASH_VERSION $SHELL $shell', so $BASH_VERSION may be set in csh as well
    – Tino
    Nov 25, 2014 at 19:48
  • @Tino well, you could do a $SHELL --version, but again SHELL might be overwritten (and all shell do not support the --version flag).
    – bufh
    Apr 22, 2015 at 11:43
  • $BASH_VERSION is very strongly advised over $SHELL --version. Needing this on a Mac trying to make sure I'm not using the system's bash over a package managed (up to date) bash has $SHELL=/bin/bash, but is correctly configured and running my desired version. Can't give another upvote here, unfortunately. Jan 9, 2020 at 4:00

There's a key shortcut that instructs current shell information to show up:

Ctrl+x Ctrl+v

From man bash

   display-shell-version (C-x C-v)
          Display version information about the current instance of bash.

This is the best choice if you have messed with environment variables.


No, everything is alright. From man bash:

          Equivalent to  -v.

It is just not as silent as usual. Try




The usual --version may give you too much multi-line boilerplate so what I am using is

bash -c 'echo $BASH_VERSION'
  • Duplicate of Pawel's answer
    – wjandrea
    Apr 1, 2017 at 14:49
  • 5
    @wjandrea This is different from Paweł Nadolski's answer. It runs the command in a new bash shell. One way this is useful is that it doesn't need the shell currently being used to be bash. Another is that, even in bash, it's possible (though not good) to set BASH_VERSION to a different value. It can even be exported as an environment variable. Yet even after running export BASH_VERSION=foobar, the method given here works, since the new bash shell resets its own BASH_VERSION automatically before performing the parameter expansion that reads it. Sep 28, 2017 at 17:02
  • @EliahKagan, in my updated & upgraded installed 16.04 LTS system installed from the 16.04.1 iso file, bash --version says 4.3.48(1)-release and apt-cache policy bashsays 4.3-14ubuntu1.2 and I have checked that the executable bash file comes from the package 'bash'. How should this be interpreted? There is a similar mismatch for usb-creator-gtk, and in that case the apt-cache output is correct. -- Can we conclude that the higher version number is the correct one (and someone forgot to update the other one)?
    – sudodus
    Feb 21, 2018 at 15:58
  • 1
    @sudodus A program's version number can be different from the version number of the APT package it comes in. That's what you're seeing here. 4.3.48... is the version of Bash, 4.3-14... is the version of the bash package.
    – wjandrea
    May 25, 2019 at 16:12
  • @EliahKagan I forgot to mention before, thanks for correcting me! I appreciate the knowledge.
    – wjandrea
    May 25, 2019 at 16:14

To only get the version and not the multiline text:

$ bash --version | head -1 | cut -d ' ' -f 4
  • Or: bash --version | awk 'BEGIN{ RS="[ \n]"; FS="[ \n]" }s{ print $0; exit}/version/{ s=1 }'
    – Luuk
    Aug 27 at 9:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .