Apple - How to replace Mac OS X utilities with GNU core utilities?
This adds symlinks for GNU utilities with g prefix to /usr/local/bin/
:
brew install coreutils findutils gnu-tar gnu-sed gawk gnutls gnu-indent gnu-getopt grep
See brew search gnu
for other packages. If you want to use the commands without a g prefix add for example /usr/local/opt/coreutils/libexec/gnubin
before other directories on your PATH
.
$ brew info coreutils
coreutils: stable 8.21
http://www.gnu.org/software/coreutils
Depends on: xz
/usr/local/Cellar/coreutils/8.20 (208 files, 9.4M)
/usr/local/Cellar/coreutils/8.21 (210 files, 9.6M) *
https://github.com/mxcl/homebrew/commits/master/Library/Formula/coreutils.rb
==> Caveats
All commands have been installed with the prefix 'g'.
If you really need to use these commands with their normal names, you
can add a "gnubin" directory to your PATH from your bashrc like:
PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH"
Additionally, you can access their man pages with normal names if you add
the "gnuman" directory to your MANPATH from your bashrc as well:
MANPATH="/usr/local/opt/coreutils/libexec/gnuman:$MANPATH"
Besides brew install coreutils
, you may also need to install some other packages, such as gnu-sed
, grep
:
brew install findutils
brew install gnu-indent
brew install gnu-sed
brew install gnutls
brew install grep
brew install gnu-tar
brew install gawk
Note that the --with-default-names
option is removed since January 2019, so each binary has to be added to the path if they are to be used without the g
prefix.
Old reference (when --with-default-names
was available): http://www.topbug.net/blog/2013/04/14/install-and-use-gnu-command-line-tools-in-mac-os-x/
I'm not sure that I would recommend replacing them; however, you can install them to a different path and utilize them that way. Overall, if you are coming from Linux and would like access to more "generic" *nix utilities, and a system similar to apt, then I would recommend looking into Macports: http://www.macports.org
It allows, for example, using the latest "generic" GCC, as opposed to/in addition to Apple's included GCC, just as an example.