OS X: How to Capture an Amazing Amount of Mac Info From the Command Line

UNIX veterans who are new to the Mac may not realize the wealth of system information that Apple's BSD UNIX (Darwin) provides from the command line. This could come in handy for programmers who, when writing scripts, need critical system information in a form that can be captured and parsed. Even the casual user may want to capture this information for a new Mac and archive it.


Of course, all this information is available via the GUI: Apple > About This Mac > System Report... But the fun part here is to do it on the command line and even save selected data to text files. (The OS X terminal app is in /Applications/Utilities.)

The terminal command I'll discuss is:


The system_profiler command reports system hardware and software configuration, and it has some nice options. You can explore those by reading the "man" page for that command.

man system_profiler

First man page for system_profiler

Two of the neat things you can do, that I'll discuss here, is to 1) display a report with a specific level of detail or 2) dump specific data types. (All of the commands below can be copied and pasted onto a command line.)

1. Level of Detail

For a general report with a defined level of detail, you could append the arguments: mini, basic or full. For example:

system_profiler -detailLevel basic

Even a basic report can be rather long, so it can be helpful to write a report to a text (or even XML) file. Here's a text file example. (The > symbol here writes the output to a named file instead of the terminal.)

system_profiler -detailLevel mini > MySystemReport.txt

By default, the text file report will go into your home directory. No personally identifying information is included in the mini report.

2. Specific Data Types

You can dump information about a specific data type by using one of the data typs as an argument. To see the available data types you can dump, enter:

system_profiler -listDataTypes

You'll get a long list that starts off looking like this:


For example, if you need to know everything about the current OS version, you could enter:

system_profiler SPSoftwareDataType

That will produce an output to the terminal something like this. (I've edited the output just a bit.)


    System Software Overview:

      System Version: OS X 10.10.1 (14B25)
      Kernel Version: Darwin 14.0.0
      Boot Volume: XXXXX
      Boot Mode: Normal
      Computer Name: XXXXX
      User Name: john (john)
      Secure Virtual Memory: Enabled
      Time since boot: 7 days 4:32

For example, you may have a Perl or Python script that needs to know the OS Version. You could parse this output in the script to capture just the OS version. How to do that is beyond the scope of this article, but, as a simple example, one could do this on the command line:

system_profiler SPSoftwareDataType | grep "System Version"

With the output: "System Version: OS X 10.10.1 (14B25)" Further, detailed parsing in a script to isolate just the OS X version number is, of course, possible.

Here's another fun one to try.

system_profiler SPStorageDataType > MyStorage.txt

I found that, frequently, full reports can drag on, and it may seem like the Mac is hung up when it's just taking its time. You can escape from a delayed output at any time with the terminal command CTRL-C.

The man page reveals that there are a lot of other things you can do with this command, but this introduction should get you started.


UNIX nameplate via Apple.