Back to Bash


How to Make MacOS More Linux-like

Up-to-date Bash shell in MacOS

One of the great things about MacOS is its command line, a terminal onto a Unix-derived set of utilities that are available for free. All you have to do is issue the following command in a Mac’s Terminal application to get a full set of them.

% xcode-select —install

Apple’s official name for these is Xcode Command Line Tools. If you’re used to a Unix-style command line, you’ll feel right at home. Well, almost.

If you come from a Linux background, you will find the tools a bit … lacking. The problem is that many of them are out of date. Apple doesn’t put a high priority on keeping them current. Another problem is that many of the utilities are derived from BSD rather than GPL Linux repositories, which means that they’re not as feature rich as their Linux counterparts.

For years, Apple made Bash (Bourne-Again Shell) its primary CLI, but even though this is Linux-like, Apple installs a very out-of-date version of Bash. The reason for this is that Apple, being a proprietary company, doesn’t like the very open GPL licensing of Bash and other Linux utilities. As a result, Apple has recently switched to making Z Shell (zsh) its default shell program, leaving an obsolescent Bash for those who might need it for Bash scripts that might not work in zsh.

There is nothing wrong with Z Shell. It has a few features that are better than Bash, such as slick directory changes, but Bash users who prefer to stick with Bash and prefer a more Linux-like command-line environment may wish to return to Bash.

Fortunately there’s a way to enjoy the best of both worlds — the lovely MacOS graphical interface that can run programs like Office 365 and Adobe products, as well as having the latest utilities from the Linux side of things.

Meet Homebrew

The secret is Homebrew, which calls itself “the missing package manager for MacOS.” If you know how to use the apt-get utilities from any derivative of Debian Linux, such as Ubuntu or Linux Mint, you will be very comfortable with Homebrew.

You first need to install Homebrew into MacOS, which you do using the Mac’s existing command-line tools by typing

% /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)

If you’re running an Intel Mac, Homebrew will put up-to-date open-source utilities in /usr/local/bin. If you’re running one of the new Apple M processors, the utilities will be placed in /opt/homebrew/bin.

Homebrew installs with the latest version of Bash. On my M1 Macbook Air, Bash is version 5.1.8. The version Apple ships is 3.2.57.

One final step is required to use the tools more conveniently. You need to add the path to the new utilities to your PATH environment. You do this by updating your ~/.bash_profile settings. Open .bash_profile in the editor of your choice and add the following line for Intel Macs

export PATH=/usr/local/bin:$PATH

or for M-based Macs

export PATH=/opt/homebrew/bin:$PATH

Type $ source ~/.bash_profile and your pathing will be set and you can run the utilities from the command line and get the right set.

Switching to Bash as Default Shell

Setting Homebrew’s Bash Shell as the MacOS Default

To make Bash your default shell, Open Terminal -> Preferences and add the path your system needs to boot Bash. For an Intel Mac this would be /usr/local/bin/bash and for a Silicon Mac /opt/homebrew/bin/bash .

Adding and Removing Applications

Homebrew doesn’t stop with just the utilities. Many of the applications that are available in Linux are also available to the Mac. For instance, if you needed to do some PHP development on your Mac, you could type

$ brew install apache2 php

Or

$ brew install ngnix php

You then have the latest general release of both the web server and of PHP (PHP 8 by default).

You can remove applications just as easily, e.g.,

$ brew uninstall ngnix php

And you can keep all your apps and utilities up to date by occasionally typing brew update followed by brew upgrade if there are updates to be applied. Notice how parallel the usage is to Linux apt.

If you run Apple silicon, most of the Homebrew utilities have been recompiled for the M processor. The utilities and apps that have not been recompiled run in Rosetta2, and they run about the same speed they do on Intel Macs. The M-compiled ones really zip along.

With your Mac now more Linux-like, you can add your favorite languages in the same way, e.g.,

$ brew install python3

Homebrew takes care of all the dependencies.

Using Brew

Brew Usage

Anyone who has used apt-get in Linux will feel right at home with these parallel Homebrew commands.


One last tip. If you would like a really attractive Bash interface with color coding and built in alias like ll for ls -l and la for ls -a, grab the contents of the default .bashrc file from Ubuntu or Linux Mint (or probably any distro that uses Bash as its default shell), and paste it into the top of ~/.bash_profile on MacOS and it transforms your environment from plain jane to Linux cool.

The synergy the Mac gets from these ‘Linux’ utilities and applications will take your command-line computing to a higher level.


Gene Wilburn is a computer generalist, tech writer, essayist, and photographer.

Leave a Reply

Your email address will not be published. Required fields are marked *