Sub topic 9
Using the softwareupdate command
This chapter assumes you can open Terminal, you have an administrator account, and you know the kinds of updates covered earlier in this tutorial (major upgrades, point updates, security updates). The softwareupdate tool does the same job as the Software Update pane in System Settings. Because it runs in Terminal, you can use it over SSH, in scripts, and when the graphical interface misbehaves.
When the command line is useful
The graphical pane is the better choice for most people. Reach for softwareupdate when you need one of these:
- You are connected to a Mac remotely and have no screen.
- You want a repeatable, scriptable check across several Macs.
- The Settings pane is stuck on "Checking for updates" and you want a second opinion.
- You want to see exact update labels, which the graphical pane hides.
The basic workflow
The tool follows a simple loop: list what is offered, install what you choose, then confirm the result.
Step 1: list available updates
Listing is safe. It contacts Apple's update servers and prints what is offered, but it installs nothing and needs no sudo.
softwareupdate --listEach entry has a label, such as Safari17.1-17.1 or macOS Sonoma 14.1-23B74. The label is the name you pass to the installer later. The output also shows the size of each update and whether it needs a restart.
Step 2: install updates
Installing changes the system, so it needs administrator rights through sudo.
sudo softwareupdate --install --recommendedThe --recommended flag installs the updates that the pane would tick by default. You can narrow or widen the selection:
| Option | Effect |
|---|---|
| `--install <label>` | Installs only the update with that label. Quote labels that contain spaces. |
| `--install --recommended` | Installs the recommended updates. |
| `--install --all` | Installs every offered update, including optional ones. |
| `--restart` | Lets the tool restart the Mac automatically when an update requires it. |
| `--download <label>` | Downloads an update without installing it. |
Without --restart, an update that needs a restart is installed but waits for you to restart. For this reason, avoid --restart on a Mac where someone has unsaved work.
Run the same preparation checks you would for a graphical update. Large updates need free space and a current backup:
df -h /
tmutil latestbackupStep 3: review the history
After installing, check what the Mac recorded.
softwareupdate --historyThis prints each installed update with its version and install date. To see the running macOS version, use sw_vers:
sw_versCompare the ProductVersion and BuildVersion with what you expected. If the history shows the update but sw_vers still reports the old version, the Mac probably has not restarted yet.
Reading the automatic update settings
The command-line tool installs updates when you tell it to. Whether the Mac checks and downloads on its own is a separate setting. You can read the system-wide values with defaults:
defaults read /Library/Preferences/com.apple.SoftwareUpdateKeys such as AutomaticCheckEnabled and AutomaticDownload show whether automatic checking and downloading are on. A value of 1 means enabled. Reading is harmless. Change these settings in System Settings unless you manage the Mac with a profile, because a management profile can override local values.
Common mistakes
- Forgetting
sudo.--listand--historywork without it.--installfails or is refused without it. - Mistyping the label. Labels are exact. Copy and paste from the
--listoutput. - Expecting an instant result. A macOS update can download for a long time before it installs. The command may seem to hang while it prepares the update.
- Ignoring errors. If an install fails, check the installer log for the reason:
grep -i softwareupdate /var/log/install.log | tail -n 20The last 20 matching lines usually show whether the failure was a download problem, a lack of space, or an authorization issue. The next chapter on troubleshooting builds on this.
Summary of the habit
- Run
softwareupdate --listand read the labels. - Check free space and your latest backup.
- Install with
sudo softwareupdate --install --recommendedor a specific label. - Restart if needed, then confirm with
sw_versandsoftwareupdate --history.
Exercise
You run softwareupdate --list and see an entry labelled Safari17.1-17.1. Which command installs only that update, and why does it need sudo?
Show answer
Run sudo softwareupdate --install "Safari17.1-17.1". Installing changes system files, so it needs administrator rights. Listing only reads from Apple's servers and needs no sudo.
Exercise
After an update, softwareupdate --history lists a new macOS version, but sw_vers still shows the old one. What is the most likely cause, and what do you do?
Show answer
The update is installed but the Mac has not restarted yet. Restart the Mac, then run sw_vers again to confirm the new version.