The Limitations of “About This Mac”
If a user wants to know what version of macOS they are running or how much RAM they have, they simply click the Apple logo in the menu bar and select “About This Mac”.
However, if you are an IT administrator managing a fleet of 500 MacBooks via SSH, or if you are writing an automated bash script that only runs if the machine has exactly 32GB of RAM, you cannot click the Apple logo. You need to extract this hardware and software data entirely from the command line.
macOS provides two incredibly powerful terminal commands for system auditing: sw_vers (Software Version) and system_profiler.
1. Getting the OS Version (sw_vers)
The sw_vers command is the fastest way to get the exact operating system build information.
sw_vers
The output is clean and structured:
ProductName: macOS
ProductVersion: 14.3.1
BuildVersion: 23D60
If you are writing a script and you only need the version number (e.g., 14.3.1) without the label, you can use a specific flag:
sw_vers -productVersion
This allows you to easily pipe the version number into an if statement to check if the machine requires a security update.
2. Deep Hardware Auditing (system_profiler)
While sw_vers is simple, system_profiler is a behemoth. It is the command-line equivalent of the macOS System Information app. It can query every single hardware sensor, USB port, Bluetooth device, and installed application on the Mac.
If you just type system_profiler and hit Enter, it will output tens of thousands of lines of data, completely overwhelming your terminal.
Querying Specific Data Types
You must tell system_profiler exactly what you are looking for using Data Types. To see a list of all available Data Types, type:
system_profiler -listDataTypes
Example: Checking Hardware Specifications
To get the core hardware overview (Processor type, Total RAM, Serial Number), use the SPHardwareDataType:
system_profiler SPHardwareDataType
Example: Checking Battery Health
If a remote employee complains their laptop keeps dying, you can check the exact cycle count and structural health of their lithium-ion battery:
system_profiler SPPowerDataType | grep -i "Condition\|Cycle Count"
Example: Listing Installed Applications
To generate a massive list of every single application installed on the machine (useful for software compliance audits):
system_profiler SPApplicationsDataType
3. Exporting to JSON or XML
If you are collecting this data to ingest into a central IT dashboard or database, standard text output is difficult to parse.
system_profiler has a brilliant feature: it can natively output its findings perfectly formatted as JSON or XML.
To export the hardware profile as a JSON file to the user’s desktop:
system_profiler SPHardwareDataType -json > ~/Desktop/hardware_audit.json
You can now feed this JSON file directly into Python, Node.js, or any enterprise monitoring system.
Conclusion
The combination of sw_vers and system_profiler provides absolute visibility into the software and hardware state of any Mac. By utilizing these tools, administrators can script complex compliance checks, automate inventory management, and diagnose hardware failures entirely over a remote terminal session.