Get OS X System Info from the Command Line

If you are stuck in a situation where you don’t have access to a graphical interface with a Mac (for example, if your only access is via SSH) and you need to get some system information from it, there are a few options that you can pursue to get the information you need from the Terminal application in OS X.

sw_vers

The sw_vers command will give you the current Mac operating system version and build number.

$ sw_vers
ProductName:	Mac OS X
ProductVersion:	10.10.5
BuildVersion:	14F27

uname

The uname command can be helpful when probing a Mac from the operating system. It is best when used with the -a flag, which makes uname behave as though all of the options except the machine processor architecture name is printed.

$ 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

The system_profiler command is a command line interface (CLI) to the System Profiler application that every Mac comes with. This command is useful in situations where it is necessary to probe a machine that you don’t have permissions to access a GUI.

$ system_profiler

The amount of information output by system_profiler makes it somewhat useless unless you know exactly what you’re looking for. There are a few better ways that system_profiler can be used.

detailLevel

The system_profiler command offers three different levels of reports: mini, basic, and full.

  • system_profiler -detailLevel mini: This will generate a text report of information from System Profiler without any personal or identifying information.
  • system_profiler -detailLevel basic: This command generates the report with only the basic hardware and network information.
  • system_profiler -detailLevel full: Generates a report with all of the available information from System Profiler.

dataType

Using system_profiler with the -detailLevel flag makes it somewhat more useful, but the real power of the tool is unleashed when using it with a specific dataType.

The view a list of the types of data that are available, the -listDataTypes flag can be used.

$ system_profiler -listDataTypes

The available data types are:

  • 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

Then, to generate a text report with just the information from one data type — for example, the hardware data type — just add the data type to the end of the command:

$ 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

You can mix and match data types to generate exactly the report that you want to see.

$ 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

Output to XML

The report generated by system_profiler can be output to XML using the -xml flag. The 'xml flag can be combined with any of the previous commands to tailor the report to contain exactly the information needed.

$ system_profiler -xml SPEthernetDataType SPFirewallDataType > ~/Documents/reports/system_profile-EthernetFirewall.xml

 

system profiler with the xml flag enabled
The XML output of the system_profiler command.