命令行获取 mac os x 系统信息
2017-07-06 20:39
2371 查看
如果你在Mac 中 处于不能访问 图形界面的情况下,例如 只能在通过 SSH 访问,而此时你需要获取一些系统信息, 使用 OS X 内置的 Terminal,你同样可以获取到你需要的系统信息。
system_profiler 输出的信息量让它显得毫无用处,除非你知道你正在查找什么信息
。以下为有效使用 system_profiler 的方法:
full。
的 system_profiler 可以根据具体情况选择不同的模式,但这绝不是 system_profiler
的终极威力,我们可以使用带有数据类型的命令模式。
传入参数
以下为可用 数据类型:
SPParallelATADataType
SPUniversalAccessDataType
SPApplicationsDataType
SPAudioDataType
SPBluetoothDataType
SPCameraDataType
SPCardReaderDataType
SPComponentDataType
SPDeveloperToolsDataType
SPDiagnosticsDataType
SPDisabledSoftwareDataType
SPDiscBurningDataType
SPEthernetDataType
SPExtensionsDataType
SPFibreChannelDataType
SPFireWireDataType
SPFirewallDataType
SPFontsDataType
SPFrameworksDataType
SPDisplaysDataType
SPHardwareDataType
SPHardwareRAIDDataType
SPInstallHistoryDataType
SPNetworkLocationDataType
SPLogsDataType
SPManagedClientDataType
SPMemoryDataType
SPNVMeDataType
SPNetworkDataType
SPPCIDataType
SPParallelSCSIDataType
SPPowerDataType
SPPrefPaneDataType
SPPrintersSoftwareDataType
SPPrintersDataType
SPConfigurationProfileDataType
SPSASDataType
SPSerialATADataType
SPSPIDataType
SPSoftwareDataType
SPStartupItemDataType
SPStorageDataType
SPSyncServicesDataType
SPThunderboltDataType
SPUSBDataType
SPNetworkVolumeDataType
SPWWANDataType
SPAirPortDataType
接下来, 根据数据类型生成一个文本文件的报告 — 例如, 硬件数据类型 — 仅在命令后边添加数据类型:
也可以使用复合数据类型 生成你想要的报告。
输出 XML 格式的报告
可以 传入参数
system_profiler 命令输出的 XML 格式的报告
sw_vers
sw_vers 命令:获取当前Mac 操作系统 版本号和编译版本号.$ sw_vers ProductName: Mac OS X ProductVersion: 10.12.5 BuildVersion: 16F73
uname
uname 命令能够读取到Mac 操作系统的信息。最佳使用格式为 uname-a
$ uname -a Darwin hostname.fqdn 14.5.0 Darwin Kernel Version 14.5.0: Wed Jul 29 02:26:53 PDT 2015; root:xnu-2782.40.9~1/RELEASE_X86_64 x86_64
system_profiler
system_profiler 命令是一个命令行接口 (CLI) 由 System Profiler 应用提供,Mac 内置了该应用。 当你没有权限访问GUI时,可以通过它来读取系统信息。$ system_profiler
system_profiler 输出的信息量让它显得毫无用处,除非你知道你正在查找什么信息
。以下为有效使用 system_profiler 的方法:
detailLevel
system_profiler 命令 提供了 3 种 不同级别的报告模式: mini, basic 和full。
system_profiler-detailLevel mini: 将会生成一个不包含个人信息及认证信息的系统信息文本报告。
system_profiler-detailLevel basic: 本命令生成仅包含基本硬件和网络信息的报告。
system_profiler-detailLevel full: 生成系统所有信息报告。
dataType
使用带有-detailLevel参数
的 system_profiler 可以根据具体情况选择不同的模式,但这绝不是 system_profiler
的终极威力,我们可以使用带有数据类型的命令模式。
传入参数
-listDataTypes可以获取到当前支持的数据类型。
$ system_profiler -listDataTypes
以下为可用 数据类型:
SPParallelATADataType
SPUniversalAccessDataType
SPApplicationsDataType
SPAudioDataType
SPBluetoothDataType
SPCameraDataType
SPCardReaderDataType
SPComponentDataType
SPDeveloperToolsDataType
SPDiagnosticsDataType
SPDisabledSoftwareDataType
SPDiscBurningDataType
SPEthernetDataType
SPExtensionsDataType
SPFibreChannelDataType
SPFireWireDataType
SPFirewallDataType
SPFontsDataType
SPFrameworksDataType
SPDisplaysDataType
SPHardwareDataType
SPHardwareRAIDDataType
SPInstallHistoryDataType
SPNetworkLocationDataType
SPLogsDataType
SPManagedClientDataType
SPMemoryDataType
SPNVMeDataType
SPNetworkDataType
SPPCIDataType
SPParallelSCSIDataType
SPPowerDataType
SPPrefPaneDataType
SPPrintersSoftwareDataType
SPPrintersDataType
SPConfigurationProfileDataType
SPSASDataType
SPSerialATADataType
SPSPIDataType
SPSoftwareDataType
SPStartupItemDataType
SPStorageDataType
SPSyncServicesDataType
SPThunderboltDataType
SPUSBDataType
SPNetworkVolumeDataType
SPWWANDataType
SPAirPortDataType
接下来, 根据数据类型生成一个文本文件的报告 — 例如, 硬件数据类型 — 仅在命令后边添加数据类型:
$ system_profiler SPHardwareDataType Hardware: Hardware Overview: Model Name: MacBook Pro Model Identifier: MacBookPro12,1 Processor Name: Intel Core i5 Processor Speed: 2.7 GHz Number of Processors: 1 Total Number of Cores: 2 L2 Cache (per Core): 256 KB L3 Cache: 3 MB Memory: 16 GB Boot ROM Version: MBP121.0167.B07 SMC Version (system): 2.28f7 Serial Number (system): XXXXXXXXXXXX Hardware UUID: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
也可以使用复合数据类型 生成你想要的报告。
$ system_profiler SPEthernetDataType SPPrintersDataType Ethernet Cards: USB Ethernet Adapter - AX88772A: Type: USB BSD name: en5 Kext name: AppleUSBEthernet.kext Location: /System/Library/Extensions/IONetworkingFamily.kext/Contents/PlugIns/AppleUSBEthernet.kext Version: 2.4.13 MAC Address: 00:0e:c6:f9:23:0b Product ID: 30506 Vendor ID: 2965 Printers: Brother HL-2230 series-05d7a2: Status: Idle Print Server: Local Driver Version: 4.5.0 Default: No System Printer Sharing: No Shared: No URI: dnssd://Brother%20HL-2230%20series-05d7a2._printer._tcp.local./F904440001 PPD: Brother HL-2230 series CUPS PPD File Version: 4.5.0 PostScript Version: (3010.106) 3 CUPS Version: 2.0.0 (cups-408.2) Scanning support: No Printer Commands: ReportLevels PrintSelfTestPage PJLBidirectional PJLWrite PJLRead CUPS filters: rastertobrother2130: Path: /Library/Printers/Brother/Filter/rastertobrother2130.bundle/Contents/MacOS/rastertobrother2130 Permissions: rwxr-xr-x Version: 4.1.0 commandtobrother: Path: /Library/Printers/Brother/Filter/commandtobrother.bundle/Contents/MacOS/commandtobrother Permissions: rwxr-xr-x Version: 4.4.0 Fax support: No Printer utility: /Library/Printers/Brother/Utilities/BrStatusMonitor.app Printer utility version: 3.9.1 PDEs: BRMLQuality.bundle: Sandbox compliant: Yes
输出 XML 格式的报告
可以 传入参数 -xml来生成 XML 格式的报告。
xml标签可以结合之前的命令定制包含所需信息的报告。
$ system_profiler -xml SPEthernetDataType SPFirewallDataType > ~/Documents/reports/system_profile-EthernetFirewall.xml
system_profiler 命令输出的 XML 格式的报告
相关文章推荐
- 如何 在 Mac OS X 里通过命令行获取 CPU 信息
- VC++获取系统信息/获取OS/获取MAC/获取本地IP/判断是否为网吧
- VC++获取系统信息/获取OS/获取MAC/获取本地IP/判断是否为网吧
- unity基础开发----Unity获取PC,Ios系统的mac地址等信息
- 关于获取系统信息,CPUID,硬盘ID,网卡MAC地址的VS2008实现
- [系统教程] Mac OS X 命令行中 10 组快捷键(导航、编辑)
- Mac 获取系统信息
- mac 系统使用 psutil 模块获取系统 cpu,内存等信息
- linux命令行获取机器的物理地址并打印及Linux获取系统信息的常用命令
- [Mac OS X Cocoa编程]如何获取其他应用程序的窗体标题以及相关信息?
- Inxi:一个功能强大的获取 Linux 系统信息的命令行工具
- c++获取系统信息(操作系统,cpu,内存,ip,mac)
- [Qt]获取Mac系统的有效网卡和序列号及硬件ID等信息(
- python中怎样获取文件的修改时间及其他系统信息状态-os.stat()
- Inxi:一个功能强大的获取Linux系统信息的命令行工具
- Mac OS X:在Windows里面使用命令行设置启动系统
- windows下使用命令行(cmd)获取系统信息
- python实现获取系统版本和mac信息上传到指定接口
- Mac OS X:在Windows里面使用命令行设置启动系统
- 使用WMI获取系统信息