[Mac OS X] 如何在终端查看 Mac OS 版本信息

本文转载至:https://www.cyberciti.biz/faq/mac-osx-find-tell-operating-system-version-from-bash-prompt/

use ssh client to login into my Mac Min server without GUI. How can I tell what version of Mac OS X operating system am I using command prompt? How do I find out Mac OS X version from Terminal app bash shell?


On Apple Mac OS X you need to use the following command to find out operating system version:

  1. system_profiler command – Show Apple hardware and software configuration.
  2. sw_vers command – Show Mac OS X operating system version.
  3. uname command – Show operating system name and more.

Determine OS X version from the command line

Open the terminal app and type the following command:
$ sw_vers
Sample outputs:

Fig. 01: Find OS X version from the command line

Fig. 01: Find OS X version from the command line


Where, you can pass the following options:

  1. -productName – Print just the value of the ProductName property.
  2. -productVersion – Print just the value of the ProductVersion property.
  3. -buildVersion – Print just the value of the BuildVersion property.

Say hello to system_profiler

You can use the system_profiler command as follows to get the same information:
$ system_profiler | less
$ system_profiler SPSoftwareDataType

Sample outputs:

Fig.02: Tell what version of OS X you are using on from the command line

Fig.02: Tell what version of OS X you are using on from the command line

Using SystemVersion.plist file

The above commands use /System/Library/CoreServices/SystemVersion.plist file. One can print the version info as follows:
$ cat /System/Library/CoreServices/SystemVersion.plist
Sample outputs:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>ProductBuildVersion</key>
	<string>15B42</string>
	<key>ProductCopyright</key>
	<string>1983-2015 Apple Inc.</string>
	<key>ProductName</key>
	<string>Mac OS X</string>
	<key>ProductUserVisibleVersion</key>
	<string>10.11.1</string>
	<key>ProductVersion</key>
	<string>10.11.1</string>
</dict>
</plist>

On Mac OS X server, try:
$ cat /System/Library/CoreServices/ServerVersion.plist

How do I find out OS X Darwin kernel version?

Simply type the following uname command to see operating system name including the machine hardware name, the nodename, the machine processor architecture name, the operating system release, the operating system name, and the operating system version:
$ uname -av
Sample outputs:

Darwin Viveks-MacBook-Pro.local 15.0.0 Darwin Kernel Version 15.0.0: Sat Sep 19 15:53:46 PDT 2015; root:xnu-3247.10.11~1/RELEASE_X86_64 x86_64

Tip: Read OS X version in audio format

Type the following bash command to hear OS X version using the say command on OS X:

say $(sw_vers) 
say $(sw_vers -productName && sw_vers -productVersion | sed 's/10//')

  • 3
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值