bash command not found - macOS
How to Install bash Command on macOS
If you’ve encountered the error “bash: command not found” on your macOS terminal, it means that the bash command line interpreter is not available by default. This tutorial will guide you through the process of installing bash on macOS.
Why bash is not included by default on macOS?
In recent versions of macOS, Apple has transitioned to using zsh (Z shell) as the default shell instead of bash. However, many users are accustomed to using bash and may prefer to have it available on their system.
Installing bash on macOS
To install bash on macOS, you can use Homebrew, a popular package manager for macOS. If you don’t have Homebrew installed, you can do so by running the following command in your terminal:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Once Homebrew is installed, you can install bash by running the following command:
brew install bash
After the installation is complete, you can set bash as your default shell by running the following command:
sudo sh -c 'echo "/usr/local/bin/bash" >> /etc/shells'
chsh -s /usr/local/bin/bash
Compatibility Note
If you encounter any commands or features that are not compatible with macOS after installing bash, you may need to adjust your scripts or configurations accordingly. Keep in mind that macOS has specific differences compared to other Unix-like systems.
Conclusion
By following the steps outlined in this tutorial, you should now have bash installed on your macOS system and be able to use it as your default shell. Remember to adjust your workflows and scripts as needed to ensure compatibility with macOS.