Making OS X Command Line Behave More Like Linux (GNU)

The command-line oddities of Mac OS X's BSD heritage drive me insane. I much prefer the behavior of the GNU toolchain, as provided by Ubuntu Linux.

To begin, first install MacPorts.

MacPorts Installation Variant +with_default_names

With several MacPorts packages, the +with_default_names variant may be specified. This causes package contents to be installed without the default "g" prefix. For example, without +with_default_names, find would be installed as gfind.


1) Use MacPorts to install the bash-completion package:

sudo /opt/local/bin/port install bash-completion

2) Edit ~/.bash_profile to load the correct autocompletion script:

if [ -f /opt/local/etc/bash_completion ]; then

Open a new terminal window, and commands should auto-complete according to the GNU specification.


The GNU version of find helpfully assumes that, if no arguments were given, you wish to search the current directory. The OS X (BSD) version has no idea what to do without a directory specification.

sudo /opt/local/bin/port install findutils +with_default_names

This package includes find, gfind, glocate, goldfind, gupdatedb, gxargs, locate, oldfind, updatedb, and xargs.

Core Utilities

This vaguely-named package provides a large number of standard GNU tools.

sudo /opt/local/bin/port install coreutils +with_default_names

Update Path

In order to call the MacPorts-installed tools by default, your path will have to be updated to include /opt/local/libexec/gnubin/. I added the following to ~/.bash_profile:

export PATH="/opt/local/libexec/gnubin/:$PATH"

About Jeff Fitzsimons

Jeff Fitzsimons is a software engineer in the California Bay Area. Technical specialties include C++, Win32, and multithreading. Personal interests include rock climbing, cycling, motorcycles, and photography.
This entry was posted in OS X, Technology and tagged , , , , , . Bookmark the permalink.

1 Response to Making OS X Command Line Behave More Like Linux (GNU)

  1. Paul H. Smith says:

    As a long time Linux user that is trying to learn OS-X Mountain Lion, thank you very much for posting this useful guide.

Leave a Reply

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