Sub topic 9
Using the softwareupdate command
What you need first
This chapter assumes you can open Terminal and run commands. It also assumes you have an administrator account, and that you know how Software Update works in System Settings. The softwareupdate command is the Terminal front end for the same update service, so it finds the same updates and installs them the same way. It is most useful when you need to script updates, work over SSH, or see more detail than the graphical interface shows.
By the end you should be able to list, download, and install updates from Terminal. You should also be able to read the update history and automatic-update settings, and know where to look when an install fails.
How the command fits in
softwareupdate is a built-in tool at /usr/sbin/softwareupdate. It talks to the same update service as System Settings. Some actions need no special rights. Listing updates and reading history work as a normal user. Installing needs administrator rights, so you run it with sudo.
Listing available updates
Start with a read-only check:
softwareupdate --listThe short form is -l. The command contacts Apple's update servers and prints each available update. The output looks like this:
Software Update Tool
Finding available software
Software Update found the following new or updated software:
* Label: macOS Sequoia 15.1-24B83
Title: macOS Sequoia 15.1, Version: 15.1, Size: 3145728KiB, Recommended: YES, Action: restart,The exact text varies by macOS version, but these fields matter in every version:
| Field | Meaning |
|---|---|
| Label | The identifier you pass to `--install`. Copy it exactly. |
| Title and Version | The human-readable name and version number. |
| Size | The download size. Compare it with your free space. |
| Recommended | Whether the update is part of the recommended set. |
| Action | What happens afterward. `restart` means the Mac must restart. |
If the command reports "No new software available.", your Mac is current for the update stream it follows. Major upgrades can appear in this list on newer systems, but they are sometimes offered only through System Settings.
By default the command scans every time you run it. When you want to act on a scan you just did, you can add --no-scan to later commands to reuse the cached results. Use that only shortly after a scan, because the cache can be stale.
Installing updates
You can install updates in three ways. The right one depends on how much control you want.
sudo softwareupdate --install --recommendedThis installs every update marked Recommended: YES. It is the closest match to clicking "Update Now" for routine updates.
To install one update, pass its label. Labels often contain spaces, so quote them:
sudo softwareupdate --install "macOS Sequoia 15.1-24B83"To install everything on the list, including updates that are not recommended, use --all:
sudo softwareupdate --install --allBe careful with --all. It can pull in optional items such as a major upgrade or a beta-channel update if they are on the list. Read the --list output first.
Restarting
Some updates need a restart. Without --restart, the tool installs what it can and tells you a restart is needed. It does not restart on its own. You can ask for an automatic restart:
sudo softwareupdate --install --recommended --restartWith --restart, the Mac restarts as soon as the install is ready. Save your work and close important apps before you run it. On a remote machine, make sure you can reach it again after the restart.
Downloading now and installing later
You can split the work into two phases. --download fetches an update without installing it:
sudo softwareupdate --download "macOS Sequoia 15.1-24B83"This helps when you want to use a fast network connection now and install during a maintenance window. Later you install the same label with --install, and the tool uses the downloaded files.
Apple silicon and authorization
On a Mac with Apple silicon, installing a macOS update needs authorization from a user who is allowed to approve system changes. Running the command with sudo is not always enough in a non-interactive session, such as over SSH or from a script. In that case the tool accepts credentials with these options:
--usernames the local account that authorizes the install.--stdinpasstells the tool to read that account's password from standard input.
A call might look like this:
sudo softwareupdate --install --recommended --restart --user adminuser --stdinpassStandard input must then supply the password. Never type a password into the command line itself, and never write it into a script file, because shell history and process listings can expose it. If you automate this, take the password from a secure source such as a secrets manager at run time, or use a management tool that holds the required authorization for you.
Checking what was installed
After an install, read the history:
softwareupdate --historyEach line shows a display name, a version, and an install date. This tells you whether an update finished, and when. The history includes macOS updates and other items that Software Update installed, so the list can be longer than you expect. You can search it with ordinary tools:
softwareupdate --history | grep -i "macOS"To confirm the version running right now, use sw_vers. It prints the product name, version, and build number. History tells you what was installed. sw_vers tells you what is running.
Reading the automatic-update settings
The tool does not have a friendly switch for each automatic option, but you can read the stored preferences:
defaults read /Library/Preferences/com.apple.SoftwareUpdateThe output is a property list. These keys are the ones you will see most often:
| Key | What it controls |
|---|---|
| AutomaticCheckEnabled | Whether the Mac checks for updates on its own. |
| AutomaticDownload | Whether updates download in the background. |
| AutomaticallyInstallMacOSUpdates | Whether macOS updates install automatically. |
| CriticalUpdateInstall | Whether security responses and system data files install automatically. |
| ConfigDataInstall | Whether configuration data files install automatically. |
A key can be missing from the output. A missing key usually means the setting was never changed from its default, so do not read absence as "off".
You can write these values with sudo defaults write, but treat that as an advanced step. The System Settings window is the supported way to change them for a single Mac. On managed Macs, a configuration profile can override the stored values, so a value you write may be ignored or reset. Read first, and change settings only if you have a reason.
Other useful options
The tool has more options than most people need. These are worth knowing:
--list-full-installerslists the full macOS installers you can download.--fetch-full-installerdownloads a full installer app into/Applications. You can add--full-installer-versionto choose a version, for examplesudo softwareupdate --fetch-full-installer --full-installer-version 14.5.--install-rosetta --agree-to-licenseinstalls Rosetta 2 on an Apple silicon Mac so that Intel apps can run.--scheduleshows whether automatic checking is on.--schedule onand--schedule offchange it on systems that still support the option.--helpprints the options supported by your macOS version.
Options change between macOS releases. Always check softwareupdate --help or the manual page (man softwareupdate) on the Mac you are working on before you put a command into a script.
Diagnosing failures
When an install fails, work from the symptom toward the cause.
- Run the list again. If the update no longer appears, it may have been superseded by a newer one. Install the new label instead.
- Check free space. Run
df -h /. A download needs room for the files, and the installer needs working space on top of that. Free up space if the volume is nearly full. - Check the label. A typo or a missing quote produces a "no such update" style error. Copy the label from the
--listoutput. - Check authorization. On Apple silicon, a missing or wrong credential stops the install. Use
--userand--stdinpass, or try System Settings. - Read the log. The installer log often names the step that failed:
grep -i softwareupdate /var/log/install.log | tail -n 20This prints the 20 most recent matching lines. Look for the last error line and the lines just before it. Search the exact message text, because the phrasing is usually specific enough to find.
- Retry on a clean state. Restart the Mac and run the install again. Network drops and interrupted downloads often clear up on a second attempt.
Common mistakes
- Forgetting
sudo. Listing and history work without it, but installing does not. Without it you get a permission error. - Leaving out quotes. A label with spaces is read as several arguments, and the install fails.
- Using
--allcasually. It can install more than you intended. - Using
--restarton a busy Mac. The restart is immediate when the update is ready. - Assuming
--historyshows pending work. It lists only finished installs. - Putting a password in a command. Use
--stdinpasswith a secure source.
Putting it together
A careful sequence for a routine update on a Mac you manage by hand looks like this:
softwareupdate --list
df -h /
tmutil latestbackup
sudo softwareupdate --install --recommended
softwareupdate --history
sw_versThe first three commands are read-only checks: what is offered, how much space is free, and where the last backup is. The fourth installs. The last two confirm the result. If the update needed a restart and you did not use --restart, restart the Mac yourself before you run the last two commands, so you see the new version.
Exercise
You run softwareupdate --list and see an update labeled macOS Sequoia 15.1-24B83 with Recommended: YES. Write the command that installs only that update, and explain why the label needs quotes.
Show answer
sudo softwareupdate --install "macOS Sequoia 15.1-24B83". The label contains spaces, so without quotes the shell splits it into several arguments and the tool cannot find an update by that name. The sudo is needed because installing requires administrator rights.
Exercise
After an overnight install, how do you tell what was installed, when it was installed, and which macOS version is running now?
Show answer
Run softwareupdate --history to see the installed items with their versions and dates. Run sw_vers to see the product name, version, and build that is running now. History shows what was installed. sw_vers shows the current system.
Exercise
An install over SSH on an Apple silicon Mac fails with an authorization error. Name one option pair that may fix it and one safety rule for using it.
Show answer
Add --user <admin account> and --stdinpass, then supply the account's password on standard input. Never put the password in the command line or in a script file. Take it from a secure source at run time.