MainspringGuides › macOS version
macOS Guide

Check Your macOS Version From Terminal (sw_vers)

Updated July 2026 · 3 min read

"What macOS version are you on?" is the first question in every bug report and compatibility check. sw_vers answers it in one word-sized command — version, build number, and product name — and it's scriptable, so your shell scripts can make decisions based on the answer. It reads system information only; nothing to undo.

sw_vers and what its fields mean

# the full report
sw_vers

The output looks like this:

ProductName:      macOS
ProductVersion:   15.6
BuildVersion:     24G84

Each field is available on its own, which is what you want in scripts:

# just the version number
sw_vers -productVersion

# just the build
sw_vers -buildVersion

Chip and kernel: uname

Two companion checks complete the picture a bug report needs:

# arm64 = Apple silicon, x86_64 = Intel
uname -m

# Darwin kernel version
uname -r

The kernel number maps neatly to macOS releases — Darwin 22 is Ventura, 23 is Sonoma, 24 is Sequoia — which is occasionally the only version signal you get in low-level logs. uname -m is the standard test for architecture-specific behavior, like choosing between Homebrew's /opt/homebrew and /usr/local prefixes.

Using it in scripts

Version-gating a script is a two-liner. Compare the major version and branch:

# run something only on macOS 14 Sonoma or later
major=$(sw_vers -productVersion | cut -d. -f1)
if [ "$major" -ge 14 ]; then
  echo "Sonoma or later — safe to proceed"
else
  echo "Older macOS — skipping"
fi

cut -d. -f1 takes everything before the first dot, so 15.6 becomes 15 and the comparison stays numeric. Compare major versions rather than full strings — a string comparison thinks 9 is greater than 15, a classic script bug from the OS X era.

The GUI routes, for completeness

  1. Click the Apple menu → About This Mac — the version appears under the Mac's name. Click the version number to reveal the build.
  2. Or open System Settings → General → About for the same information plus chip and serial number.

Terminal still wins when you need to paste the answer somewhere: sw_vers && uname -m gives a support thread everything in one copyable block.

Version number to marketing name

Apple's tools print numbers, not names — nothing built in translates 15 to "Sequoia." The mapping you'll actually use:

For a fuller software report — macOS version plus computer name, kernel, and time since the last reboot — system_profiler SPSoftwareDataType bundles it into one block. And when the real question is "am I current?", ask the update engine directly: softwareupdate --list checks Apple's servers and prints any updates waiting. Both commands are read-only, so there's nothing to undo.

One habit for bug reports: paste the whole triple — sw_vers; uname -m; uname -r — so the reader gets version, architecture, and kernel in one block. Reports that include the build number get answered faster, because the build pins down exactly which update the machine is on, point release and security patch included.

Whatever the version, tune it

Mainspring supports the macOS versions that matter and turns 90+ hidden settings into labelled, reversible toggles — no version-specific defaults commands to research.

Try Mainspring free →

Signed & notarized by Apple · 1-day free trial · $29 once

While you're checking versions

If the point of the check is "am I up to date?", the softwareupdate command answers that from the same window — our guide to updating macOS from Terminal covers it.