本文转载至: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:system_profilercommand – Show Apple hardware and software configuration.sw_verscommand – Show Mac OS X operating system version.unamecommand – 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
Where, you can pass the following options:-productName– Print just the value of the ProductName property.-productVersion– Print just the value of the ProductVersion property.-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 SPSoftwareDataType$ system_profiler | less
Sample outputs:
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.plistfile. One can print the version info as follows:
$ cat /System/Library/CoreServices/SystemVersion.plist
Sample outputs:
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 ; root:xnu-3247.10.11~1/RELEASE_X86_64 x86_64
Tip: Read OS X version in audio format
Typethe following bash command to hear OS X version using the saycommand on OS X:
如果觉得《[Mac OS X] 如何在终端查看 Mac OS 版本信息》对你有帮助,请点赞、收藏,并留下你的观点哦!