Get system information from the Mac command line
Commands for finding out about your Mac: which macOS and hardware, what’s on
the disks, what the logs say, and how apps are set up. All of them only read,
apart from shortcuts run, which does whatever the shortcut does. I ran them
on macOS 27.2.
sw_vers and system_profiler: which Mac, which macOS
sw_vers # ProductVersion: 27.2, BuildVersion: 26B123
sw_vers -productVersion # just 27.2
system_profiler SPHardwareDataType
system_profiler -json SPSoftwareDataTypeSPHardwareDataType gives the model, chip, cores and memory, which is what
a support request usually needs. It also prints the serial number and
hardware UUIDs, so remove those before pasting it anywhere public.
system_profiler -listDataTypes lists the other reports; running it with no
type at all is slow and enormous.
diskutil: disks and FileVault
diskutil list
diskutil info /System/Volumes/Data
fdesetup statusdiskutil list shows the internal disk and its APFS volumes, plus any disk
images and simulator volumes that are mounted. One trap: diskutil info /
says Encrypted: No even with FileVault on, because / is the sealed
system volume; the FileVault: Yes line just below it is the one that
counts. fdesetup status (“FileVault is On.”) answers it directly. Other
diskutil verbs erase and partition disks; stick to list and info
unless you mean it.
For disk images, hdiutil create and hdiutil attach still work on macOS
27.2 but print warnings pointing to diskutil image as their replacement.
log: read the system log
In zsh, the default shell, log is a built-in command, so log show fails
with “too many arguments”. Use the full path:
/usr/bin/log show --last 30m --style compact --predicate 'process == "powerd"'The log is huge: five minutes of errors alone ran to thousands of lines here.
Always use --last and a --predicate. Informational and debug messages
are hidden unless you add --info or --debug, and many values show as
<private>.
softwareupdate: check for updates
softwareupdate --listThis only checks (“No new software available.” here, in about five seconds). Installing needs an administrator.
plutil and defaults read: settings and property lists
Apps keep settings in property lists. plutil reads them, even the binary
ones:
plutil -p /System/Library/CoreServices/SystemVersion.plist
plutil -extract CFBundleShortVersionString raw /System/Applications/Calculator.app/Contents/Info.plist
plutil -convert json -r -o - /System/Library/CoreServices/SystemVersion.plistThe second line prints an app’s version number, handy in scripts. Always
give -convert an output with -o: without it, plutil rewrites the file
in place.
defaults read shows an app’s saved settings:
defaults read com.apple.dock autohide # 0 = off
defaults read -g AppleLocale # en_US
defaults read com.apple.finder AppleShowAllFilesThe last one printed “Could not find key”, which only means the setting has
never been changed from its default. This page stops at reading;
defaults write changes settings.
osascript and shortcuts: scripts and shortcuts from Terminal
osascript -e 'display notification "Backup finished" with title "Terminal"'
osascript -l JavaScript -e 'JSON.stringify({sum: [1,2,3].reduce((a, b) => a + b)})'
shortcuts list
shortcuts run "Name" -i input.txt -o output.txt # runs a shortcut by nameosascript runs AppleScript or JavaScript; scripts that control other apps
ask for Automation permission the first time. shortcuts runs any shortcut
by name; the Automate your Mac guide covers both.