OS X: Get OS version info in Terminal #

$ sw_vers
ProductName:    Mac OS X
ProductVersion: 10.6.4
BuildVersion:   10F569
$ sw_vers -productVersion
10.6.4

Especially handy when resetting a password in single user mode, since the method varies based on which version of OS X is running.

Update 1

Here's another way to check; great for use on offline OS X installs:

$ grep -2 ProductVersion /Volumes/OfflineVolumeName/System/Library/CoreServices/SystemVersion.plist
	<key>ProductUserVisibleVersion</key>
	<string>10.11.6</string>
	<key>ProductVersion</key>
	<string>10.11.6</string>

Update 2

Update 3

system_profiler can query all sorts of hardware information, e.g., system_profiler SPSerialATADataType | grep "Medium" to check whether the internal drive is Rotational or Solid State. Run system_profiler -listDataTypes to list the available datatypes; see Get OS X System Info from the Command Line for more information.

Update 4

In Linux, find model identifier and serial number via dmidecode -t system.

Update 5

Under macOS 10.12 Sierra or higher, retrieve serial number via ioreg -l | grep IOPlatformSerialNumber.

/mac | Aug 14, 2010


Subscribe or visit the archives.