sw_vers - macOS


sw_vers

Overview

The sw_vers command provides detailed information about the macOS operating system running on a computer. It displays essential system details like the operating system version, build number, kernel, and hardware model.

Syntax

sw_vers [options]

Options/Flags

  • -productVersion: Displays the OS product version, e.g., “macOS Monterey”.
  • -buildVersion: Shows the OS build version, e.g., “21A559”.
  • -kernelVersion: Displays the macOS kernel version, e.g., “Darwin 21.6.0”.

Flags:

  • -help: Displays help information.

Examples

  • Get the macOS version:
    sw_vers
    
  • Display the OS build version:
    sw_vers -buildVersion
    
  • Show the kernel version:
    sw_vers -kernelVersion
    

Common Issues

  • The command may fail if the OS is not properly installed or corrupted.
  • Ensure the command is run with administrative privileges if necessary.

Integration

sw_vers provides essential system details that can be used in scripts and automation tasks. For example, it can be used to check the OS version before installing software or running a specific script.

Related Commands

  • system_profiler: Displays detailed hardware and software information.
  • uname: Prints operating system information, including the kernel version.
  • Apple Developer Documentation