Check Your macOS Version From Terminal (sw_vers)
"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
- ProductVersion is the number everyone means by "macOS version" — 13.x is Ventura, 14.x is Sonoma, 15.x is Sequoia. The digits after the first dot are the point release, which matters for security-fix questions.
- BuildVersion identifies the exact build. Two Macs can both say 15.6 but carry different builds; support engineers and beta testers care about this line.
- ProductVersionExtra appears only when a Rapid Security Response is installed (Ventura and later), showing a letter like
(a)appended to the version.
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
- Click the Apple menu → About This Mac — the version appears under the Mac's name. Click the version number to reveal the build.
- 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:
13.x— macOS Ventura14.x— macOS Sonoma15.x— macOS Sequoia
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.
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.