Sub topic 15
Checking your setup from Terminal
What this chapter covers
System Settings shows you the state of your Mac one pane at a time. Terminal can report the same facts in a few lines of text, which you can copy into a support request or save as a record. This chapter shows five read-only commands that confirm the macOS version, pending updates, FileVault, Time Machine and hardware identity. It also explains how to read their output and where they can mislead you.
Prerequisites. This chapter assumes you have finished Setup Assistant and signed in with your Apple Account. It also assumes you can open Terminal (in Applications, then Utilities) and that your Mac user is an administrator. You don't need shell scripting experience, but you should know that a command is typed after the prompt and run with Return.
Why verify from Terminal
Each setup step earlier in this tutorial has a screen where you turned something on. Those screens can be skipped or dismissed by accident, and some features (such as FileVault) only take effect after a restart or a background process. A command-line check gives you an answer that does not depend on remembering what you clicked.
The commands below only read information. None of them changes a setting, so you can run them safely at any time.
The five checks at a glance
| Question | Command | What a healthy result looks like |
|---|---|---|
| Which macOS is installed? | `sw_vers` | A current version and build number |
| Are updates waiting? | `softwareupdate --list` | No new software, or only updates you expect |
| Is FileVault on? | `fdesetup status` | `FileVault is On.` |
| Is a backup destination set? | `tmutil destinationinfo` | A named destination, not "No destinations configured" |
| Which Mac is this? | `system_profiler SPHardwareDataType` | Model, chip and serial number that match your records |
Check 1: the macOS version
sw_versThe output has three lines: ProductName, ProductVersion and BuildVersion. The version is the number you see in System Settings under General, then About. The build is a short code such as a number followed by a letter. It matters when you report a problem, because two Macs with the same version can differ in build if one received a later fix.
Run this command before and after you install updates. If the version does not change after an update you believe you installed, the installation did not finish. Restart the Mac and check again.
Check 2: pending updates
softwareupdate --listThis asks Apple's update servers what applies to your Mac, so it needs a network connection and can take several seconds. If nothing is waiting, it reports that no new software is available. Otherwise it lists each item with a label, a title, a version and a size. Items that need a restart are marked.
Two points to keep in mind:
- The list is read-only. To install, use System Settings, General, Software Update, or the
softwareupdate --installoption once you know the label of what you want. This chapter stays with verification. - A major macOS release may appear in the list as an upgrade rather than as an ordinary update. Seeing it there does not mean your Mac is behind on security fixes. Check whether your current release also has its own updates listed.
Check 3: FileVault
fdesetup statusWhen FileVault is enabled, the command prints FileVault is On. When it is not, it prints FileVault is Off. You do not need sudo for this status check.
There is a third state worth knowing. Right after you turn FileVault on, the disk may still be converting in the background. In that case the command prints that FileVault is on and adds a line about encryption in progress. Treat the Mac as protected only once that extra line is gone.
Check 4: Time Machine destinations
tmutil destinationinfoIf you have chosen a backup disk, the output lists it with fields such as name, kind and an ID. If you have not, the command reports that no destinations are configured. That second result means no Time Machine backup is running, even if you meant to set one up.
Some tmutil actions need administrator rights, and in some configurations Terminal needs Full Disk Access (System Settings, Privacy & Security) before Time Machine data is readable. If you see a permission error instead of a result, that is a permissions problem and not proof that no backup exists. Confirm in System Settings, General, Time Machine.
Also note that a configured destination does not mean a backup has completed. If the destination is a disk that is not currently plugged in, it will still be listed. Check the Time Machine pane for the date of the latest backup.
Check 5: hardware identity
system_profiler SPHardwareDataTypeThis prints the hardware profile: model name, model identifier, chip, memory and serial number. It is useful in two places:
- When you compare the Mac with the device list in your Apple Account. A signed-in device appears there under its name, and the serial number lets you tell two similar Macs apart.
- When you contact support, which will ask for the model and serial number.
The serial number identifies your specific Mac. Do not post it publicly. Share it only with Apple or your support provider.
Putting the checks into one script
If you set up Macs often, you can run all five checks in one pass. Save the following as check-mac.sh.
#!/bin/bash
# Read-only post-setup report for a Mac.
echo "== macOS version =="
sw_vers
echo
echo "== Pending updates =="
softwareupdate --list 2>&1
echo
echo "== FileVault =="
fdesetup status
echo
echo "== Time Machine =="
tmutil destinationinfo 2>&1
echo
echo "== Hardware =="
system_profiler SPHardwareDataType
echo
if fdesetup status | grep -q "FileVault is On"; then
echo "RESULT: FileVault is enabled."
else
echo "RESULT: FileVault is NOT enabled. Turn it on in System Settings."
fiRun it with bash check-mac.sh. The 2>&1 on two lines sends error messages into the same output, so a failed update lookup or a permission message appears in the report instead of disappearing. The last block uses grep -q, which prints nothing and only sets the exit status, so the if can branch on whether the text matched.
Reading the results together
A single command can look fine while the setup is still incomplete. Combine the answers:
- Version current, updates empty, FileVault on, backup listed. The setup is complete.
- FileVault on, but
tmutilreports no destinations. The Mac is protected against theft of its data, but a failed disk or accidental deletion could lose files. Set up Time Machine. - Updates listed that you installed yesterday. The install may be waiting for a restart. Restart, then run
sw_versandsoftwareupdate --listagain. - Hardware details do not match what you expect. If the model or serial number is not your Mac, you may be on a different machine or looking at the wrong entry in your device list.
Common mistakes
- Treating
softwareupdate --listwith no network as "no updates". If the Mac is offline, the command may print an error or find nothing. Confirm you are connected first. - Assuming a command run in one Terminal window reflects a change made seconds ago. FileVault conversion and update installs take time. Wait, then run the command again.
- Pasting output with the serial number into a public forum. Remove it first.
Exercise
You run fdesetup status and it prints "FileVault is On." followed by a line saying encryption is in progress. Is the setup finished, and what should you do?
Show answer
Not quite. FileVault is enabled, but the disk is still being converted in the background. Keep the Mac plugged in and wait for the extra line to disappear, then run fdesetup status again to confirm it reports only that FileVault is On.
Exercise
tmutil destinationinfo lists a backup disk, but the disk is unplugged. Does that prove you have a recent backup, and where should you look instead?
Show answer
No. A configured destination is listed whether or not the disk is connected, so it only shows that a target is set. Open System Settings, General, Time Machine and check the date of the latest backup there.