man sw_vers | tail shows you the file you need to look at, namely:

/System/Library/CoreServices/SystemVersion.plist
/System/Library/CoreServices/ServerVersion.plist

When you cat those files, you learn what you need to know.

Answer from Clinton Blackmore on serverfault.com
🌐
Apple Support
support.apple.com › en-us › 109033
Find out which macOS your Mac is using - Apple Support
From the Apple menu  in the upper-left corner of your screen, choose About This Mac. The window that opens might look different from the example shown here, but it always includes the macOS name and version number. If you need to know the build number as well, click the version number to see it.
🌐
Server Fault
serverfault.com › questions › 54631 › how-can-you-determine-the-version-of-os-x-on-a-machine-that-doesnt-boot
mac osx - How can you determine the version of OS X on a machine that doesn't boot? - Server Fault

man sw_vers | tail shows you the file you need to look at, namely:

/System/Library/CoreServices/SystemVersion.plist
/System/Library/CoreServices/ServerVersion.plist

When you cat those files, you learn what you need to know.

Answer from Clinton Blackmore on serverfault.com
Videos
March 28, 2021
🌐 YouTube Instructional Technology Specialists at EPISD How to find the Operating System or OS your Mac is Running - YouTube
October 7, 2021
7.19K
🌐
Super User
superuser.com › questions › 75166 › how-to-find-out-mac-os-x-version-from-terminal
macos - How to find out Mac OS X version from Terminal? - Super User

You have a few options:

sw_vers -productVersion 

system_profiler SPSoftwareDataType

Either will do what you need, and will have an output format that's parseable (if that's what you're after).

Answer from delfuego on superuser.com
🌐
How-To Geek
howtogeek.com › home › windows › how to check which version of macos you're using
How to Check Which Version of macOS You're Using
May 2, 2018 - If you're not using the latest version of macOS, you can install it from the Mac App Store---assuming your Mac's hardware is still supported by Apple. To do this, click the "Software Update" button in the About This Mac window, which will open the Mac App Store.
🌐
Nordlayer
help.nordlayer.com › docs › macos-version-number
How to find your MacOS version number
If you want your team to use macOS 12.6 or a later version, enter, for example, 12.6.0 in the Device Security Posture Monitor Operating system version field.
🌐
Stack Exchange
unix.stackexchange.com › questions › 582 › how-can-i-tell-what-version-of-os-x-im-on-from-the-command-line
osx - How can I tell what version of OS X I'm on from the command line? - Unix & Linux Stack Exchange

sw_vers

My suggestion is to use sw_vers. Example output as of 10.6.4:

> sw_vers 
ProductName:    Mac OS X
ProductVersion: 10.6.4
BuildVersion:   10F569

The answer that suggested system_profiler | grep 'System Version' is what I have tried to use in the past, but it has 2 problems.

  1. It is slow since it generates a full system_profiler dump of the machine, gathering all hardware and software inventory information.
  2. The output of system_profiler has changed over time. e.g. output of grep for 'Serial Number' on 10.6.4 is "Serial Number (system): ZNNNNNZNZZZ", whereas on 10.4.11 it was "Serial Number: ZNNNNZNZZZZ" - importance being the parse-ability of the output and the add " (system)" piece can be problematic unless you are expecting the change.
Answer from Mike Gray on unix.stackexchange.com
🌐
Apple Support
support.apple.com › en-us › 109065
Find the software version on your iPhone, iPad, or iPod touch - Apple Support
To find the software version installed on your device, go to Settings > General > About.
🌐
Stack Exchange
apple.stackexchange.com › questions › 399380 › how-can-i-see-which-macos-version-is-installed-on-an-external-disk-without-boot
system information - How can I see which macOS version is installed on an external disk, without booting into it? - Ask Different

You can read the SystemVersion.plist on that particular volume-

/Volumes/<volume_name>/System/Library/CoreServices/SystemVersion.plist 
Answer from fd0 on apple.stackexchange.com
Find elsewhere
🌐
Digital Citizen
digitalcitizen.life › macos-version
How to check your macOS version: All you need to know - Digital Citizen
January 26, 2021 - Apple was aware that this issue might come up fairly often, so they made it easy to check the version of your Mac operating system (macOS). How easy? Well, it only takes two clicks, and the info is displayed on your screen. First, click on the Apple logo on the top left corner of your screen.
🌐
Mac Business Solutions
mbsdirect.com › mbs-blog › article-what-os-version-are-you-running-herersquos-how-to-find-out
What OS Version Are You Running? Here’s How to Find Out. - Mac Business Solutions - Apple Premier Partner
May 10, 2019 - On the Mac, click the Apple menu in the upper-left corner of the screen and choose About This Mac. A window opens, displaying the name (macOS High Sierra shown here) and version (10.13.4) of the running version of macOS.
🌐
Wikipedia
en.wikipedia.org › wiki › MacOS
macOS - Wikipedia
4 days ago - Tools such as XPostFacto and patches ... of newer versions of macOS on systems not officially supported by Apple. This includes a number of pre-G3 Power Macintosh systems that can be made to run up to and including Mac OS X 10.2 Jaguar, all G3-based Macs which can run up to and including Tiger, and sub-867 MHz G4 Macs can run Leopard by removing the restriction from the installation DVD or entering a command in the Mac's Open Firmware interface to tell the Leopard ...
🌐
Macworld
macworld.com › home › feature
macOS compatibility guide:Find the macOS version that runs on your Mac | Macworld
June 7, 2022 - Find out if you can run macOS Tahoe on your Mac, whether you will get all the features, and which version of macOS is best for your Mac with our macOS compatibility guide.
🌐
Wikipedia
en.wikipedia.org › wiki › MacOS_version_history
macOS version history - Wikipedia
3 days ago - Apple called it "the largest update ... of RAM to be installed. The single DVD works for all supported Macs (including 64-bit machines). New features include a new look, an updated Finder, Time Machine, Spaces, Boot Camp pre-installed, full support for 64-bit applications (including graphical applications), new features in Mail and iChat, and a number of new security features. Leopard, on the Intel platform, is the first Open Brand UNIX 03 registered version of ...
🌐
Linus Tech Tips
linustechtips.com › software › operating systems › windows
Challenge: Determining OS version without booting into it. - Windows - Linus Tech Tips
February 27, 2018 - So here's a fun little challenge. Suppose someone hands you a laptop or desktop and it doesn't boot fully into Windows. You are left with no choice but to reinstall the operating system. You have to know which version to install - Home Premium, Professional, etc, because you can only reinstall it...
🌐
OS X Daily
osxdaily.com › 2019 › 02 › 16 › check-what-mac-os-version-on-mac
How to Check What Mac OS Version is Running on a Mac
February 18, 2019 - Have you ever needed to know which version of Mac OS was on a computer? For some users the answer may be never, but others may need to know exactly what version of Mac OS system software is running…
🌐
University of Iowa
its.uiowa.edu › services › macos › how-tell-what-version-macos-you-are-running
How to tell what version of macOS you are running | Information Technology Services - The University of Iowa
It is often important to know what version of macOS you have in order to perform other tasks. You can easily check your current version though the "About This Mac" tool.
🌐
Stack Exchange
apple.stackexchange.com › questions › 216909 › what-version-of-os-x-originally-shipped-on-my-mac
macos - What version of OS X originally shipped on my mac? - Ask Different

I use the program Mactracker when I want to know about specific machines throughout Apple's History. With your model number you can identify all there is to know about that mac you have.

It is available form the App Store for both Mac and iOS devices.

Answer from TheWellington on apple.stackexchange.com