Skip to content

GNU coreutils

The GNU ls, cp, date, sed-adjacent tools, because macOS ships the BSD ones.

Homebrew formula

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

AlternativeTypeTrade-off
The BSD tools already on macOSBuilt inDifferent flags, same jobs, nothing to install
uutils-coreutilsOpen sourceA Rust reimplementation of GNU coreutils, drop-in in most cases
busyboxOpen sourceOne binary with small versions of everything, more common on embedded systems

Install

brew install coreutils

Links

This post is licensed under CC BY 4.0 by the author.
Last updated on