Is there a Terminal command to know the macOS installed but from an external hard drive or from macOS recovery?

How can I know the macOS version (such as 10.12.1) installed on the startup drive if I don't have the password (or has filevault encryption and I don't have the password). I wonder if there's a way to know it by using a Terminal command from macOS recovery or by starting from an External storage disk.


Solution 1:

The ProductVersion is stored within the SystemVersion.plist file in CoreServices. This can be read using defaults:

defaults read /System/Library/CoreServices/SystemVersion ProductVersion

When you're accessing the startup disk from another volume, you'll need to provide the full path to both defaults and /System:

/Volumes/Macintosh\ HD/usr/bin/defaults read /Volumes/Macintosh\ HD/usr/bin/System/Library/CoreServices/SystemVersion ProductVersion

Solution 2:

You can use sw_vers

Internal Drive:

➜  ~ sw_vers
ProductName:    Mac OS X
ProductVersion: 10.13.4
BuildVersion:   17***

External Drive:

You can simply consult the files that sw_vers use

➜  ~ man sw_vers

[...]

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

So in order to access to theses files on your external volume, you can simply do:

✗ cat /Volumes/YOUR_VOLUME_NAME/System/Library/CoreServices/SystemVersion.plist