How to update macOS and apps from the Terminal command line

The Apple Mac has a comprehensive set of commands that can be accessed from a Terminal command prompt and you can even update the system and apps with them using the software update command.
Although Mac apps have to be run through a graphical user interface, the same is not true of system functions. There is a wide range of commands that can be used instead of their graphical counterparts and sometimes they provide extra features that are not normally available.
It is useful to know these commands, even if you do not always use them because sometimes they can be very useful.
For example, you might want to download an update, but save the installation until later. The usual way to check for and install updates is to open the Mac App Store and click the Updates tab.
The updates are listed and there is an Update button, but the options are limited to trying in an hour, tonight or reminding you tomorrow – click the little arrow at the right of the Update button for these options.
The command line softwareupdate command used in a Terminal window is a bit more flexible.
Check for software updates
Go to the Utilities folder and open Terminal. At the command prompt, enter:
softwareupdate --list
This checks for updates to macOS and apps and lists them like this:
The output for you will be different to mine and I have two updates available, one for macOS and one for iTunes.
The asterisk before the update name means that it is recommended and there is also a [recommended] notice. Some minor updates may be optional and if they are not labelled as recommended, they could be ignored, or at least put off until a later date. Recommended updates are best installed as soon as it is possible.
There is another label that shows whether a [restart] is necessary. The macOS update does require a restart, but the iTunes update does not – it doesn't have a [resart] label.
Install updates from Terminal
So how do you install an update? This is easy and you just need to type:
softwareupdate --install UpdateName
I have an update available called iTunesXPatch-12.7.4 and so the command to install it is:
softwareupdate --install iTunesXPatch-12.7.4
Here is what the Terminal window looks like when executing this command:

It reports what is happening, so it says 'Downloading iTunes', 'Installing iTunes', 'Done with iTunes.' Some people report that updates download and install faster using this command line tool than when using the Mac App Store. It did not seem much faster to me but try it and see.
Some updates have long and complicated names and they must be typed exactly, or if you are lazy like me, click and drag over the text, press Cmd+C to copy it and Cmd+V to paste it into the command line.
If an update name contains spaces, it must be enclosed in quotes like this:
softwareupdate --install "macOS High Sierra 10.13.4 Update-"
More command line update options
Instead of installing a software update immediately, it can be downloaded and saved. Replace --install with --download like this:
softwareupdate --download UpdateName
After checking for updates and getting a list, some may be recommended but others may not be. To download and install all recommended updates, use:
softwareupdate -ia
There are two command arguments here and they have been combined into one:
-i is the same as --install
-a is the same as --all
So -ia means install all updates. Suppose you only wanted to download and install recommended updates. In this case the command to use is:
softwareupdate -ir
As before, the shortened form is used here and -i is short for --install and –r is short for –recommended.
Authorise updates
Some updates require an admin password to authorise them. You will automatically be prompted to enter the password if necessary, but you can pre-empt the question. Whenever admin commands are used it is customary to add 'sudo' at the start of the line. So to download and install all updates for your Mac, you would enter:
sudo softwareupdate -ia
Some updates require a reboot, but often it is a good idea to reboot anyway. The command 'sudo reboot' will restart the Mac and it can be tagged onto the end of the update command like this:
sudo softwareupdate -ia; sudo reboot
That downloads all updates and restarts the Mac and you can go and get a coffee while it does it.
One last command to remember is one that shows whether macOS automatically checks for updates. Enter:
sudo softwareupdate --schedule
You need to enter your admin password for this, hence the sudo at the start of the line. That command tells you whether scheduled checks for updates are on or off. You can add 'on' or 'off' to the end of the line to set it as you prefer.
Related items you will like...



Brilliant Online Courses!
Join the private Facebook group!
Add new comment