(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 '16 at 3:24

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 '11 at 17:21
  • 32
    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 '11 at 20:42
  • 2
    typo, should be something like [ "${BASH_VERSINFO}" -lt 4 ] or [ "${BASH_VERSINFO[0]}" -lt 4 ] – bufh Apr 22 '15 at 11:51
  • Too verbose, much easier with askubuntu.com/a/899187/1004 – sorin Apr 1 '17 at 14:30
  • 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 '17 at 8:53

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.

  • 11
    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 '13 at 9:23
  • 1
    +1 bash --version does not show the bash you are currently using. – gabeio Mar 6 '14 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 '14 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 '15 at 11:43

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 '17 at 14:49
  • 4
    @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. – Eliah Kagan Sep 28 '17 at 17:02
  • @EliahKagan Good point, thanks! – wjandrea Sep 28 '17 at 17:23
  • @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 '18 at 15:58

To only get the version and not the multiline text:

$ bash --version | head -1 | cut -d ' ' -f 4

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.