I am accustomed to updating systems with sudo apt get update
and would like to ensure MacOS security updates are installed from the command line. This `software update' command was issued on my machine:
$ softwareupdate -l
Software Update Tool
Finding available software
No new software available.
The article indicates that the unix equivalent is:
sudo softwareupdate -r
The list command returned that no updates are available: Can I expect that if there were security updates for the OS, they would be listed for download? I do not want to be misinterpret the response and think that the box is updated when it is not updated.
Best Answer
Yes, security updates show up as recommended updates but
softwareupdate -r
at least on Mojave is invalid. Note softwareupdate will not install updates for things from the App Store.If you run
softwareupdate -l
on a system that is due security updates you can see them prefixed with a*
character in the --list output which means they are recommended and will be processed by the-r
option.This is from a system untouched for a month - as you can see there is a recommended Safari update and a recommended Security update that requires a restart.
You may either list all available updates with
-l
(which is closest tosudo apt-get update
in that it doesn't download or install packages), download with-d
or download and install them with-i
. The-r
switch on its own is not accepted.softwareupdate -i -r
. Fromman softwareupdate
:In this case the security update required a restart and this was advised. The
-R
(capital) or--restart
option can automate this but you would want to check user session status before forcing a restart and potentially losing session state/unsaved changes/etc. Passing--restart
requires root privilege so the command in this case would besudo softwareupdate -irR
softwareupdate -d -r
If you wanted all instead of recommended you would replace
-r
with-a
.Note that
sudo
on Mojave is required only for the--restart
option but this rather old man page indicates that it was also required for installation in the past.