How to Find which macOS version you are running?

  • HOME
  • >
  • MAC
  • >
  • How to Find which macOS version you are running?
Last Updated: 

When automating build processes or install scripts, it may be necessary to adjust steps taken based on the operating system version. Knowing which macOS version you are running is important and finding such information via the command line is critical when automating build process that can be used by various engineers with different versions of macOS. Below we will cover two methods to find quickly which macOS version you are currently running.

💡 Did you know? Apple's operating systems started as the "Classic" Mac OS in 1984, followed by just "Mac OS" in 1996. The current operating system is macOS but was originally branded "Mac OS X" until 2012, then "OS X" until 2016.

👉 If you'd rather to use a point-and-click solution, instead of command line, to find out which version of macOS you are running, then check out the guide from apple's website which also include the detail of latest versions available. See

Using system_profiler

The system_profiler command line utility provide system hardware and software configuration. The details that you can get from this utility goes way beyond the macOS version and can be slow to run. If you are only interested in the macOS version, make sure to use the command line argument SPSoftwareDataType. See example below.

[me@me-macOS: ~]$ system_profiler SPSoftwareDataType

    System Software Overview:

      System Version: macOS 10.14.6 (18G103)
      Kernel Version: Darwin 18.7.0
      Boot Volume: Macintosh HD
      Boot Mode: Normal
      Computer Name: jdoe-macOS
      User Name: John Doe (jdoe)
      Secure Virtual Memory: Enabled
      System Integrity Protection: Enabled
      Time since boot: 70 days 14:18

The benefit of using system_profiler is that it will properly reflect the macOS branding.

If you are only interested in getting your macOS version then sw_vers is probably better suited as it is an utility specificaly made to print Mac OS X operating system version information.

[me@me-macOS: ~]$ sw_vers 
ProductName:	Mac OS X
ProductVersion:	10.14.6
BuildVersion:	18G103

If you only care about the version number then you can run sw_vers -productVersion this way you don't need to parse the output, all you get is the version number. You can also use the argument -productName or -buildVersion, check man sw_vers for the details.

[me@me-macOS: ~]$ sw_vers -productVersion

If you only care about major and minor version, then you could simply use bash substitution.

[me@me-macOS: ~]$ vers=`sw_vers -productVersion`
[me@me-macOS: ~]$ echo ${vers%.*}

How to get the macOS Friendly Name?

While I will use the numerical version of macOS in automation scripts, it is sometime helpful to know what is the friendly name or code name of the corresponding version.

Unfortunately neither sw_vers or system_profiler the friendly codename of your macOS version. You may find it in some random output with system_profiler but it may vary from version to version and depending on the software installed. Any alternative you may find online with parsing the license agreement or calling a remote support page would be unreliable and inconsistent between versions.

To get the firendly name, and use it in your automation scripts reliably, you will have to use an associative array containing all the versions and names then do a lookup based on your current version number.

👉 Find some examples of Bash Associative Array with my Complete Guide on How To Use Bash Arrays.

Below is a summary table of the Major.Minor macOS versions and the corresponding Code Name.

Version Code Name
10.15 Catalina
10.14 Mojave
10.13 High Sierra
10.12 Sierra
10.11 El Capitan
10.10 Yosemite
10.9 Mavericks
10.8 Mountain Lion
10.7 Lion
10.6 Snow Leopard
10.5 Leopard
10.4 Tiger
10.3 Panther
10.2 Jaguar
10.1 Puma
10.0 Cheetah
Related mac posts that you may like...
The Most Useful Bash Shortcuts That You Will Want To Use
A detailed review of the most useful Terminal and Bash shortcuts to improve your productivity when typing command-lines and how to customize the ones you don't like.
How To Format Date and Time in Linux, macOS, and Bash?
This guide covers how to format date and time in Linux, Mac, and the Bash shell. Includes how to do date shell operations like adding days or comparing dates.
How To Use Option as Meta Key in macOS Terminal?
The Meta Key is a modifier key that can be quite helpful to improve your productivity while working in a terminal and bash. This post cover how to enable from the command line the Meta Key in macOS Terminal.
How To Change Preferences from the Command Line on macOS?
Introduction to the command line 'defaults' on Mac with examples on how to programmatically change user preferences from a shell script and terminal.