Updating macOS from the Terminal


It is possible to update macOS from the Terminal.


Simple Example


Update All


softwareupdate -i -a


Update One


Use softwareupdate with the lowercase L option to list possible updates.


Then, use the lowercase I option with the name of an update. Use quotes to escape spaces in the update name.


softwareupdate -l 
* macOS Update One

softwareupdate -i "macOS Update One" 


Complete Example


Commands that change the system must be run as root. In practice, this means you must be logged on as an administrator. And, most commands must be run with sudo.


Note: The first user created on new a Mac is an administrator.


# An unprivileged user can list updates. 
softwareupdate -l 
* macOS Update One

# To install updates, log in as an administrator. 
su adminuser

# You must use sudo with the softwareupdate -i option. 
sudo softwareupdate -i "macOS Update One" 

# Or
sudo softwareupdate -i -a


Notes


I expect to be able to update the system from the terminal with a simple command:



This would mirror what happens when using System Settings > Software Update.


Unfortunately, updating from the terminal works in unexpected and unhelpful ways.


For example, while updating through System Settings can be done by an unprivileged user, updating from the terminal must be done with sudo. That also means the user must be in the sudoers file. In other words, they must be an administrator. So, you must first log in as an administrator, which forces you to type your password. And, you must use sudo, which forces you to type your password again. So, compared to a graphical update, you must type your password twice to do the same thing.


A further wrinkle is that the graphical Software Update is supported by Power Nap. And an update will continue in the background if initiated there. Whereas, Terminal commands will be interrupted when your Mac goes to sleep. And you will have to begin the download or installation from scratch. You can change your sleep settings, but then you must change them back after the update. This is a bad workflow.


There are also unanswered questions. For example, does Software Update (graphical) compete with softwareupdate (terminal)? For example, if I begin an update from the terminal then is that downloading a duplicate copy of the same file as Software Update? I don't know the answer to that question. But the programs don't appear to share state. If I start an update with one, that is not reflected by the other program. This just creates confusion and needlessly doubles the amount of data downloaded.


I wish there was a clear and reliable procedure for updating a Mac from the terminal.


With the way things stand, I recommend enabling Power Nap and then updating through System Settings. This seems to be the upgrade path that is best supported by recent versions of macOS.



References


How to Update macOS Using a Simple Terminal Command | MacRumors

Big Sur & "softwareupdate -a -i --restart" ? | MacRumors Forums

Administrator | Apple Support

How to prevent Mac sleep from command line? | Stack Exchange

Update macOS on Mac | Apple Support

What is Power Nap on Mac? | Apple Support


Created: Tuesday, July 25, 2023

Updated: Tuesday, July 25, 2023




/gemlog/