36

These are the series of commands I entered that cause the problem.

brew install bash
echo '/usr/local/bin/bash' | sudo tee -a /etc/shells
chsh -s /usr/local/bin/bash

Now when I start my terminal, I get this.

Last login: Sun Apr  7 14:40:48 on ttys008
login: /usr/local/bin/bash: No such file or directory

[Process completed]

I can't write to the terminal unless I got to Shell->New Command and then type in "\bin\bash"

Anyone know a solution to this?

Charles Duffy
  • 280,126
  • 43
  • 390
  • 441
Yvan Niyonzima
  • 461
  • 1
  • 4
  • 3
  • 1
    Well, *does* `/usr/local/bin/bash` exist? And if so, can you run it from a manually-created shell? If yes to the former and no to the latter, then the next step is to look into *why* it's not runnable -- missing dynamically-linked libraries or the like. – Charles Duffy Apr 07 '19 at 19:01
  • That said, this is probably a better fit for one of our sister sites, such as [apple.se], [unix.se] or [SuperUser](https://superuser.com/); it's neither asking about writing software, or about tools exclusively for the purpose of writing software. – Charles Duffy Apr 07 '19 at 19:03
  • 1
    ...anyhow, until you figure out what's wrong with your `/usr/local/bin/bash`, you can just `chsh -s /bin/bash` to switch the default back. – Charles Duffy Apr 07 '19 at 19:04
  • (BTW, I'm surprised it works when you type `\bin\bash`; it should be `/bin/bash`, with forward slashes rather than backslashes). – Charles Duffy Apr 07 '19 at 19:06
  • ...it would be helpful to actually know that the `brew install bash` *worked*. Without being shown any logs from it, the only thing we're being told is that the executable wasn't actually created, which certainly implies that it failed and whatever logs that generated were simply ignored. – Charles Duffy Apr 07 '19 at 19:13
  • https://stackoverflow.com/a/55011144/8258079 – Richard Barber Apr 09 '19 at 05:27

3 Answers3

90
  1. Go to "System Preferences" > "Users & Groups"
  2. Click the "Lock" icon and authenticate
  3. Right-click the your user icon and select "Advanced Options"
  4. Change the value for "Login shell" to /bin/bash
fedorqui
  • 275,237
  • 103
  • 548
  • 598
Amol Ray
  • 901
  • 5
  • 3
  • I specifically use bash from Homebrew, which has a symlink at `/usr/local/bin/bash`. Should I expect any issues setting it to that rather than the system `/bin/bash`? – Sinjai Nov 30 '21 at 21:01
  • 1
    @Sinjai I'm also using homebrew w/ symlink, and changing my default shell via the Users & Groups settings worked for me with no issues so far – xxkazunarixx May 15 '23 at 19:51
10

The "System Preferences" option did not work for me cause there wasn't any "Advanced Options" within "Users & Groups" (For reference: I am running Monterey 12.2). The following worked for me:

  • Open a new terminal. For now it will show /usr/local/bin/bash: No such file or directory.
  • Press Command + , which should open the terminal preferences. Terminal Preferences
  • Select the Command (complete path) option for the Shells open with: choice.

  • Enter the value as /bin/bash or /bin/zsh based on your preference.

  • Close and reopen the terminal. You should now have a working terminal.

ThePretendProgrammer
  • 1,449
  • 10
  • 16
2

I hope below Steps can help

Step 1. Once bash has been installed using brew

brew install bash

Step2. You can verify the path of the available bash by using the following command:

/usr/bin/which -a bash

You now have the default /bin/bash and your newly configured /opt/homebrew/bin/bash from homebrew.

By using the following commands, you can verify the version of both

  • /bin/bash --version
    

    (probably version 3.)*

  • /opt/homebrew/bin/bash --version
    

    (probably version 5.)*

Step 3. Hence, once this has been confirmed for homebrew installation, make a softlink of it to facilitate easy access,

sudo ln -s /opt/homebrew/bin/bash /usr/local/bin/bash

Step 4. To make it Standard Shell, modify the file /etc/shells using the following command:

sudo vim /etc/shells

Add an entry at the end as /usr/local/bin/bash

Step 5. Enter the following command to create a newly configured bash shell for the current user

sudo chsh -s /usr/local/bin/bash

Step 6. To verify, close the Terminal completely and reopen it, then execute.

  • echo $SHELL
    

    to verify the Current SHELL

  • echo $BASH_VERSION
    

    to verify the current Bash Shell version

Step 7. Done