(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.

| improve this answer | |
  • Great! I also found the list of switches for bash. – Zabba May 2 '11 at 17:21
  • 35
    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.

| improve this answer | |
  • 12
    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
  • $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. – user2943160 Jan 9 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.

| improve this answer | |

No, everything is alright. From man bash:

          Equivalent to  -v.

It is just not as silent as usual. Try



| improve this answer | |

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

bash -c 'echo $BASH_VERSION'
| improve this answer | |
  • 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, 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
  • 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 '19 at 16:12
  • @EliahKagan I forgot to mention before, thanks for correcting me! I appreciate the knowledge. – wjandrea May 25 '19 at 16:14

To only get the version and not the multiline text:

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

If you are on Windows and, instead, want to know what version of Git Bash you're running, it is part of Git for Windows.
So the Git Bash version is:

git --version

git version 2.23.0.windows.1

On my same machine when I run:



To update to the latest version, generally you will want to download and install the latest version of git for Windows as per FAQ. Settings/customizations should be preserved if installed in the appropriate configuration folders.

| improve this answer | |
  • Thanks Sheryl, but isn't this a Ubuntu forum? – Kurankat Mar 29 at 23:13
  • Guess so. Sorry about that. I was looking for Git Bash, Google gave me this post, and I didn't pay attention to which StackExchange site I was on. I posted so I could find the information easily next time, as it took several tries to find even this post. – SherylHohman Mar 30 at 3:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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