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.
The sw_vers command will give you the current Mac operating system version and build number.
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.
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.
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.
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.
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.
The available data types are:
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:
You can mix and match data types to generate exactly the report that you want to see.
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.