Getting the macOS version from the command line

Question

From the Terminal, or an SSH session, how can I find the version of my OS?

Environment

  • Mac OS X
  • macOS

Answer

Run the command: sw_vers

Additional Information

The command outputs 3 lines: ProductName, ProductVersion, and BuildVersion. If you wish to get just one of them, you can use one of these:

  • sw_vers -productName
  • sw_vers -productVersion
  • sw_vers -buildVersion

For example:

bash-3.2$ sw_vers
ProductName:    Mac OS X
ProductVersion: 10.11.6
BuildVersion:   15G1421

Details

Article ID: 1484
Created
Tue 5/26/20 6:00 PM
Modified
Mon 8/31/20 9:05 AM