Update macOS from the Command Line

February 1, 2019

Since version 10.14 (Mojave), the software update function within macOS has been within the System Preferences app, under Software Update. If you have full access to your Mac, there's no particular reason not to use it from within there. If, however, you can only SSH into your machine -- or if you have a problem that is preventing you from using your machine as usual -- you may need to run updates from the command line. This guide explains how to do just that.

Find out which version you are currently running

To discover which version of macOS you have installed, run:


      sw_vers

You should see an output that looks like this:

ProductName: Mac OS X
ProductVersion: 10.14.3
BuildVersion: 18D42

Find out which updates are available

To obtain a list of available updates for your machine, run:


      softwareupdate -l

If successful, you’ll see an output similar to this:

Software Update Tool

Finding available software
Software Update found the following new or updated software:
* macOS 10.14.3 Update-
macOS 10.14.3 Update ( ), 1925808K [recommended] [restart]

Install available updates

If you want to install all the available updates, run:


      softwareupdate -i -a 

You should see an output similar to this:

Downloading macOS 10.14.3 Update
Downloaded macOS 10.14.3 Update
Installing macOS 10.14.3 Update
Done.

If you want to install only one of the available updates, rather than all of them, run the following (replacing UPDATE with the name of the update you want within the list):


      softwareupdate -install UPDATE

If the package name has spaces in it, you will have to insert quotes around it. For example:


      softwareupdate --install 'macOS Mojave 10.14.3'

Restart your Mac

At this point, you will need to restart your Mac by running:


      sudo reboot

Alternatively, if you want your Mac to restart automatically once the update is installed, add --restart to the original string. In the above example, that would mean you’d run:


      softwareupdate -i -a --restart

WARNING If you are using your Mac remotely and you have Filevault switched on, ensure that you run the following command before restarting:


      sudo fdesetup authrestart -1

This is necessary because FileVault requires that you unlock your Mac with your password before macOS loads at all — which, obviously, is impossible for a remote user to do. By running sudo fdesetup authrestart, this feature is disabled on a one-time basis. To learn more about how to shut down or reboot your Mac using the command line, take a look at our guide.

Download updates, but not install them

To download any available updates without installing them, simply replace the --install in the above instructions with -d. So, to download macOS Mojave 10.14.3 you’d run:


      softwareupdate --d 'macOS Mojave 10.14.3'

Versions

macoS: 10.14.3
Notice an error?

Have we got something wrong? Please let us know and we’ll fix it right away.

Categories
Mac macOS

Join the Discussion

Your email address will not be published. Required fields are marked *