1

I was trying to install home brew (I am new to the command line and was following some tutorials on how to get up and running with github).

So I was following this Unofficial Update Method: Compile Bash from Source Code using Homebrew (https://security.stackexchange.com/questions/68202/how-to-patch-bash-on-osx-in-wake-of-shellshock)

This is what I typed into the Terminal:

$ xcode-select --install

$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

$ brew doctor

$ brew update

$ brew install bash

$ sudo mv /bin/bash /bin/bash_old

$ sudo mv /bin/sh /bin/sh_old

$ sudo chmod a-x /bin/bash_old /bin/sh_old

And now Bash doesnt work anymore :( When I open Terminal it displays this message:

You have new mail.
login: /bin/bash: No such file or directory
[Process completed]

5
  • Boot your install media, and undo the changes you made.
    – Zoredache
    Sep 2, 2015 at 20:23
  • If you're using Grub loader, you can edit kernel command line (with 'e' key) and add init=/bin/sh_old
    – levif
    Sep 2, 2015 at 22:11
  • @Zoredache how do i boot install media?
    – verity1007
    Sep 2, 2015 at 22:27
  • 1
    You must write lines similar to sudo ln -s /usr/local/Cellar/bash/4.3.25/bin/bash /bin/bash (with the correct version of the installed bash and the correct path) else you will never find it. You moved and renamed bashand sh with different names (bash_old/sh_old) you miss to create the links.
    – Hastur
    Sep 3, 2015 at 12:08
  • @Hastur I cant type anything into the terminal any more, is there any way I can install bash again?
    – verity1007
    Sep 4, 2015 at 0:14

1 Answer 1

1

Terminal attempts to load /bin/bash (or whatever the default shell for the user is). Since you moved that, it doesn’t know what to do unless you tell it where to look instead. There are several ways to override the default login shell in OS X, that don’t require a current working shell.

For a specific user:

System Preferences → Users & Groups → right click user → Advanced Options… → Login shell

advanced user options

For the current user:

Terminal → Preferences… → General → Shells open with: → Command (complete path)

terminal default shell

For a specific Terminal profile:

Terminal → Preferences… → Profiles → ‹profile› → Shell → Run Command Also untick the “Run inside shell” box.

profile default shell

When you have a working shell, you can rename the binaries back to their originals and then use homebrew and use the same process to set /usr/local/bin/bash as the login shell. There is no need to replace binaries in /bin as the shell uses binaries from multiple directories using the PATH environment variable, including /usr/local/bin, which is the homebrew default install directory.

You must log in to answer this question.

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