Is it possible to actually update bash to version 4.0 in OSX Yosemite?


This article and this thread refer to the same question, but they install a new shell side-by-side with the old one. Is there a way to directly update the old bash shell?

  • 5
    There is no need to do that. In fact, it is always a good idea to keep the original one. Two or more versions of bash can be installed at the same time, and you can set whichever one you like to be the default
    – lupincho
    Commented Jun 28, 2015 at 12:32
  • Essentially Apple's Software Update would be responsible for changing the version of BASH on the system, like it did with the update to BASH for Shellshock. So unless Apple provides an update then there is no direct way to update to the latest version of GNU BASH that came installed as part of OS X. An indirect way would be to download it yourself, by one means or another, and instal it and then set it as your default shell. Whether or not you choose to remove the shipped version or Apple updated version, that's up to you. Commented Jun 28, 2015 at 17:26
  • 2
    For anyone else like me coming here from Google, starting with macOS Catalina (10.15) you can set the default shell to zsh pretty easily. zsh will be the default shell in macOS going forward. Many similar features to bash. And most importantly it's an up-to-date version. Steps here: support.apple.com/en-us/HT208050
    – Prime624
    Commented Apr 13, 2022 at 23:35
  • Probably in Yosemite (10.10) you can, but in El Capitan (10.11) System Integrity Protection support.apple.com/en-au/HT204899 will prevent you modifying /bin and thus /bin/bash
    – Jason S
    Commented May 28, 2022 at 2:37

6 Answers 6


Apple will not update Bash, because the latest version is licensed under GPLv3, which Apple cannot use. They have updated most of their other shells though. ZSH for example is mostly up to date.


After a bit of research, this seems like the primary issue:

When people distribute User Products that include software under GPLv3, section 6 requires that they provide you with information necessary to modify that software. User Products is a term specially defined in the license; examples of User Products include portable music players, digital video recorders, and home security systems.

This would require that otherwise closed-source software, have its GPL'd portions be made modifiable by the public, which would obviously be an issue for Apple.

  • Comments are not for extended discussion; this conversation has been moved to chat.
    – bmike
    Commented Nov 19, 2017 at 0:15
  • 11
    This explanation does not make sense. Shipping a GPL (v3 or otherwise) binary does not mean that the rest of the OS would need to be released. The rest of the OS does not link to bash. The "Tivoization" clause might explain why bash can't be updated on, say, an Apple TV, but not really on a desktop Mac. Furthermore, "GPL'd portions" already would need to be made modifiable by the public; v3 would not change that. I would believe that the patents clause of GPL v3 would be sufficient to deter Apple from touching GPL v3 code.
    – jamesdlin
    Commented Jun 19, 2018 at 17:41
  • Why would that be an issue for Apple? Bash is already open source (all versions ≥1.14 are available via GNU @ ftp.gnu.org/gnu/bash & the version included with macOS (currently v3.2) is available via Apple @ opensource.apple.com/source/bash), but it could be modified regardless.
    – voices
    Commented Dec 7, 2018 at 9:28
  • 1
    @tjt263 It's about the differences between GPLv3 and GPLv2, which the version Apple uses, is still licensed under. Commented Dec 9, 2018 at 0:19
  • 3
    Right, Bash3.2 is licensed under GPLv2. Bash4.x is licensed under GPLv3. So what? You said: "Apple will not update Bash, because the latest version is licensed under GPLv3, which Apple cannot use." Why can't they? "This would require that otherwise closed-source software, have its GPL'd portions be made modifiable by the public, which would obviously be an issue for Apple." Why is that an issue? They do that already. It's already modifiable by the public. All software is. Especially when it's FOSS and they're giving away the source code on their site to anyone who wants it.
    – voices
    Commented Dec 9, 2018 at 1:11

As @William said in his answer, Apple does not provide bash 4 due to GPL restrictions. You can install bash 4+ however and also can make it your default shell (including for Terminal and iTerm2) by doing the following.

Install Bash 4 via Homebrew

First install the newer version of bash. There are various ways of doing that, I prefer Homebrew.

  • Install Homebrew as described at http://brew.sh.
  • Install bash using brew install bash.

Bash 4 is now available on your PATH (assuming Homebrew bin is on your path). However, it is not yet your default shell. You can find where it is located by running which bash. In my case it is at /usr/local/bin/bash.

Using Bash 4

Since it is on your PATH, you can start a Bash 4 session with just bash or it can be used in scripts by using a Shebang.

For example, this will use a specific bash instance.

...your script...

This will use the first bash on the PATH.

#!/usr/bin/env bash
...your script...

You can also set the bash path for specific profiles in Terminal/iTerm2 using the steps described in @user136952's answer.

Making Bash 4 the default

As mentioned above, after installing Bash 4 is still not the default shell. To make bash the default you need to do two more steps.

First, add the Bash 4 path to your /etc/shells file so that it is an allowed login shell. As described in /etc/shells, this file has the list of valid login shells. After adding the new bash path my /etc/shells looks like the following:

# List of acceptable shells for chpass(1).
# Ftpd will not allow users to connect who are not using
# one of these shells.


Next we use chsh to make it your default shell. So any sessions for that user will use that shell. You can read more about this in Change the Shell in Mac OS X Terminal, but the actual command is very straightforward.

chsh -s /usr/local/bin/bash

Now the new bash is our default login shell. If you open Terminal or iTerm2 and run bash --version you should see the new version. Note the "License GPLv3+" which is why Apple doesn't bundle it with macOS.

$ bash --version
GNU bash, version 4.4.12(1)-release (x86_64-apple-darwin16.6.0)
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
  • 4
    Based on article/thread he linked to I think he really meant "not default" by saying not side-by-side. My answer makes 4 the default so 3 is no longer seen. The fact that the old bash happens to still be taking up some disk space doesn't seem like a big issue to me.
    – studgeek
    Commented Nov 18, 2017 at 0:44
  • 2
    +1 by me. Yes, OP doesn’t want this, but the question belongs to the community and if this helps other people, awesome. It might not get a check as the answer the OP selects, but that doesn’t make it a bad answer.
    – bmike
    Commented Nov 19, 2017 at 0:17
  • 3
    On High Sierra, sudo chpass -s /usr/local/bin/bash changes my shell for root/sudo only. To change for my regular login, I must run the command without sudo. This might be an Active Directory thing; I’m not sure. Commented May 9, 2018 at 21:29
  • 3
    Instead of using the #!/usr/local/bin/bash shebang, look into using #!/usr/bin/env bash (explanation). This will run the script with whatever version of bash is reachable by the environment that's launching the script, i.e. whatever which bash returns. It's a more portable solution that using specific paths. We can't expect other users to install bash through homebrew. Commented Dec 26, 2018 at 21:51
  • 2
    @IllyaMoskvin, I originally used a specific path because I wanted to show how to use it explicitly. I've updated the examples to have both.
    – studgeek
    Commented Jan 5, 2019 at 2:42

Is it possible to actually update bash to version 4.0 in OSX Yosemite? Yes.

  1. Download / Install homebrew http://brew.sh/ by running this command in terminal.

    ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  2. Quit and reopen your terminal. then type

    brew install bash
  3. Change the default shell via the terminal gui with the literal path of your new bash (EDIT: I have yet to find a CLI way that works )

enter image description here

Is it possible to actually update bash to Apple’s provided bash version 4.0 in OSX Yosemite?

EDIT: No. Not in the way the op is asking. E.g upgrade the current install by way of replacing itself. It has been noted in other answers that Apple has not updated bash due to licensing issues. However downloading an updated and separate version of bash and using it as your default shell is the canonical solution, for most interpreters. Take python for example. You do not upgrade 2.7 to 3.5 you download a separate version and change your default.

  • 17
    You can set the default via the CLI with: sudo chpass -s /usr/local/bin/bash. Note: It's best to point to the symlink in /usr/local/bin/ that way Brew can handle upgrades without having to change your environment each time.
    – sansSpoon
    Commented Dec 8, 2017 at 9:38
  • 5
    what are the risks of going with a non-Apple shell?
    – 3pitt
    Commented Oct 17, 2018 at 6:30
  • 12
    sudo bash -c 'echo /usr/local/bin/bash >> /etc/shells' then chsh -s /usr/local/bin/bash will set the default shell for the terminal Commented Dec 19, 2018 at 4:50
  • 1
    @3pitt There's very little risk in installing a newer bash to /usr/local/bin/bash because it leaves the system /bin/bash alone. So any system dependencies on bash 3 will be preserved.
    – wisbucky
    Commented Dec 27, 2021 at 4:32

The side-by-side install with an update to your shell (via chsh or the GUI) will fail for scripts. Scripts often use env bash, which reverts to the OS X bash version. So, what you want may not be the complete update of bash, but a side-by-side install that always returns the newer version of bash (i.e. even when env is invoked).

So, to handle this:

1) install bash via Homebrew, as the other commenters have posted

2) set your login shell to this new version (via the GUI or chsh command as others have posted)

3) set /usr/local/bin (or the path to the new bash version) ahead of /bin on your $PATH variable, by adding this to your ~/.bash_profile: export PATH=/usr/local/bin:$PATH

  • This will break scripts that expect bash version 3 - ie Apple supplied scripts - you need to use sde by side
    – mmmmmm
    Commented Jun 12, 2018 at 11:30
  • 1
    A fair point. Been running like this for some time now and no issues. Maybe Apple provides the full path in its scripts or it just hasn't hit a snag. For apple system level scripts, i.e. not from a shell, it never calls the .bash_profile anyway, so it would only impact something you run directly in a terminal anyway.
    – cwingrav
    Commented Jun 13, 2018 at 20:08
  • 5
    @Mark I can't think of an instance where v ≥4.x would break a script written for v ≤3.x. Can you?
    – voices
    Commented Dec 7, 2018 at 9:53

You can install another version of Bash without homebrew

  • Go to GNU Bash
  • Download the version you want (here)
  • And follow the steps here: https://gist.github.com/samnang/1759336

    Download and install bash version you want Replace X.X (in bash-X.X) with the version you want e.g 4.4

    curl -O http://ftp.gnu.org/gnu/bash/bash-X.X.tar.gz
    tar xzf bash-X.X.tar.gz
    cd bash-X.X
    ./configure --prefix=/usr/local && make && sudo make install

    Add the new shell to the list of legit shells

    sudo bash -c "echo /usr/local/bin/bash >> /private/etc/shells"

    Change the shell for the user

    chsh -s /usr/local/bin/bash

    Check for Bash 4 and /usr/local/bin/bash...

    echo $BASH && echo $BASH_VERSION

    You might want to add an alias if you want the bash command to use it. Place in your ~/.bash_profile

    alias bash="/usr/local/bin/bash"
  • 1
    This strikes me as a good approach, but I wonder this: Why would one not simply replace the antique /bin/bash? Is it because it's needed for compatibility with other "antique" software Apple distributes in MacOS?
    – Seamus
    Commented Jan 11, 2020 at 21:52
  • 1
    This will dump all the installation directories into /usr/local. If you'd rather have them organized in a bash-X.X directory, append /bash-X.X to the prefix parameter in the ./configure command.
    – shoe
    Commented Oct 21, 2020 at 5:02
  • 1
    @Seamus you're not allowed to modify the /bin directory unless you disable SIP.
    – Andy
    Commented Jun 2, 2021 at 7:19

For M1 Macs -

You can update bash by doing

brew install bash

assuming that you already have Home-brew. This will install the latest version of bash. You can check you installation by running -

brew info bash

To update the shell, simply restart the terminal and check the version of bash using -

bash --version

Hope this helps.

  • Is this any different from the answer for Intel Macs? Also, step 1 should be "install homebrew".
    – benwiggy
    Commented Jun 29, 2022 at 14:54
  • I have not worked on intel macs but M1s have an older version of bash so I put this here. Also, my answer does mention "assuming homebrew is installed". Commented Jul 2, 2022 at 1:06
  • this worked well
    – Awesome-o
    Commented Feb 26 at 20:37

You must log in to answer this question.

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