How to Use the ‘sw_vers’ and ‘uname’ Commands to Check macOS Version via Terminal

The Compliance Audit Problem

If a user wants to know what version of macOS they are running, they simply click the Apple Logo in the top left corner and select “About This Mac.”

However, if you are an IT Administrator running an automated audit script across 500 employee MacBooks, clicking a graphical menu is impossible. You need a command-line tool that can instantly query the operating system, extract the exact version number, and return it in a format that a script can read and parse.

To programmatically audit Apple hardware and software architecture, administrators rely on two distinct terminal commands: sw_vers (Software Version) and uname (UNIX Name).

1. Identifying the macOS Version (sw_vers)

The sw_vers command is a macOS-specific utility designed to provide exact release information.

If you run it without any flags:

sw_vers

The terminal will output three lines of information:

  1. ProductName: macOS
  2. ProductVersion: 14.5
  3. BuildVersion: 23F79

While this is easy for a human to read, a script only wants the raw number. If you are writing a script that only installs a specific security patch if the Mac is running exactly version 14.5, you can isolate that specific data point using a flag:

sw_vers -productVersion

This command silences all the noise and outputs only the raw number (e.g., 14.5), allowing you to easily assign it to a bash variable for conditional logic.

2. Understanding the UNIX Kernel (uname)

While sw_vers tells you the Apple marketing name for the operating system, it hides the true underlying architecture.

macOS is built on top of a highly modified UNIX core called “Darwin.” If you are compiling complex C++ software from scratch, or installing low-level networking tools, the software doesn’t care about “macOS Sonoma.” It cares about the exact version of the Darwin kernel and the physical CPU architecture (Intel vs. Apple Silicon).

To extract this deep system telemetry, you use the universal UNIX command uname.

To see the absolute full string of kernel information:

uname -a

This will output a massive string detailing the Darwin version, the exact date the kernel was compiled, and the hardware architecture.

3. Identifying Apple Silicon vs. Intel

The most common use of uname in modern Mac administration is differentiating between older Intel processors (x86_64) and modern Apple Silicon processors (ARM64 / M1 / M2 / M3).

If you write an automated deployment script that downloads Google Chrome, you must ensure it downloads the correct binary for the physical CPU.

You can isolate the machine hardware architecture using the -m flag:

uname -m
  • If the Mac has an Intel chip, it will output: x86_64
  • If the Mac has an Apple Silicon chip, it will output: arm64

You can then wrap this output in a simple if/else statement in your bash script to dynamically route the software installation based on the physical hardware.

Conclusion

The sw_vers and uname commands provide the foundational telemetry required for macOS fleet management. By extracting clean, scriptable data regarding the operating system version and the physical CPU architecture, administrators can build robust, conditional deployment logic that adapts to diverse hardware environments.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.