Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

In Red Hat the file /etc/redhat-release contains the operating system version data (such as "Red Hat release X.X (Final)").

Is there any similar mechanism in Mac OS X that can be used programatically to get the operating system version data (such as "Mac OS X 10.5.8")?

share|improve this question

2 Answers 2

up vote 3 down vote accepted

In case you are looking for more details to the kernel, you can also query the sysctl interface which provides the kernel ostype, version and other details.

  • To get the ostype : sysctl kern.ostype
  • To get the osversion : sysctl kern.osversion
  • To get the version : sysctl kern.version
  • To get the osrevision : sysctl kern.osrevision

More details here : http://developer.apple.com/mac/library/documentation/Darwin/Reference/ManPages/man8/sysctl.8.html

share|improve this answer
1  
Just FYI: On Ubuntu, it's "kernel" instead of "kern". And for these keys, the output is the same as uname -a (or the various subsets from other options like -s, -r, -v, etc.) –  Dennis Williamson Sep 6 '09 at 22:01
1  
uname -a on a Mac: "Darwin <machine name>.local 9.8.0 Darwin Kernel Version 9.8.0: Wed Jul 15 16:55:01 PDT 2009; root:xnu-1228.15.4~1/RELEASE_I386 i386" –  warren Sep 7 '09 at 3:21

Found the answer:

/usr/bin/sw_vers
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.