GNU coreutils
The GNU ls, cp, date, sed-adjacent tools, because macOS ships the BSD ones.
What it does
macOS inherits BSD userland, whose flags differ from GNU’s in ways that break any script written on Linux — date -d, sed -i without an argument, readlink -f, cp --reflink, stat -c, sort -V.
Homebrew installs GNU coreutils with a g prefix: gdate, gls, gcp, greadlink, gstat. Nothing system-level is replaced.
Putting them first
PATH="/opt/homebrew/opt/coreutils/libexec/gnubin:$PATH"That shadows the BSD tools with unprefixed GNU names for your shell only.
Put the
gnubin directory on PATH for interactive shells, not system-wide. macOS scripts and installers expect BSD behaviour and some of them break subtly when GNU tools answer instead.Alternative to
| Alternative | Type | Trade-off |
|---|---|---|
| The BSD tools already on macOS | Built in | Different flags, same jobs, nothing to install |
| uutils-coreutils | Open source | A Rust reimplementation of GNU coreutils, drop-in in most cases |
| busybox | Open source | One binary with small versions of everything, more common on embedded systems |
Install
brew install coreutils