Finding the OS Version via the command line

I was working on a user’s MacBook Air, trying to resolve a kernel panic.

I had been working in their account (the only account on the machine). I shifted my attention to something else.

After being unattended, it locked the screen.  The user was not around, and I was trying to figure out the version of the OS. Looking at the logs, it looked like it a networking library was missing or damaged. I suspected that a system update would fix this. But, how to figure out the OS version, when I couldn’t log in?

I thought I could reboot into Single User Mode and find it that way. 

Sure ‘nuff!

Here’s the string: 

sw_vers | grep -0 '[0=9]*\.[0-9]*\.[0-9]*'

It was running 10.9.2. I restarted the system, which then told me it had updates to install. I clicked on “Install Updates and Reboot.” A few minutes later, the Air restarted. I held command-S, and booted back into Single User Mode.

Ran the sw_vers again, and it replied “10.9.4″


(I had discovered the utility of SUM a few years ago, when I trying to troubleshoot lost user accounts. It’s been a very handy tool on some of the more odd or difficult issues, since)