macOS Command - softwareupdate


macOS 使用交流 QQ 群:658095824,V : ez-code


本文基于 macOS 11.2

一、关于 softwareupdate

softwareupdate : system software update tool,系统软件更新工具


相关GUI

系统偏好设置 – 软件更新

在这里插入图片描述
在这里插入图片描述



相关配置文件

/Library/Preferences/com.apple.SoftwareUpdate.plist

这里记录着 softwareupdate 相关配置数据

$ plutil -p /Library/Preferences/com.apple.SoftwareUpdate.plist 
{
  "AutomaticallyInstallMacOSUpdates" => 0  # 自动安装 macOS 更新
  "AutomaticCheckEnabled" => 0  # 是否开启 自动检测 
  "AutomaticDownload" => 0 # 自动下载
  "ConfigDataInstall" => 0 
  "CriticalUpdateInstall" => 0
  "InactiveUpdates" => [
  ]
  "LastAttemptBuildVersion" => "11.2 (20D64)"
  "LastAttemptSystemVersion" => "11.2 (20D64)"
  "LastBackgroundSuccessfulDate" => 2020-09-24 11:35:54 +0000
  "LastFullSuccessfulDate" => 2021-03-09 10:36:43 +0000
  "LastRecommendedMajorOSBundleIdentifier" => ""
  "LastRecommendedUpdatesAvailable" => 0
  "LastResultCode" => 2
  "LastSessionSuccessful" => 1
  "LastSuccessfulDate" => 2021-03-09 10:36:47 +0000
  "LastUpdatesAvailable" => 0
  "PrimaryLanguages" => [
    0 => "zh-Hans-CN"
    1 => "zh-Hans"
    2 => "fr-CN"
    3 => "en-GB"
  ]
  "RecommendedUpdates" => [  # 建议安装的更新
  ]
  "SkipLocalCDN" => 0
}

你也可以使用 defaults 命令来修改配置
defaults 使用方法可参考:https://blog.csdn.net/lovechris00/article/details/113280758


二、使用示例

以下示例大部分来自 How To Update Apple OS X Using Command Line Software Update Tool


查看更新

$ softwareupdate -l
Software Update Tool

Finding available software
No new software available.

除了查看命令,其他命令均需要管理员权限


应用建议的更新(recommended updates)

所有建议的更新

$ sudo softwareupdate -r

安装系统所有的更新

$ sudo softwareupdate -i -a

$ softwareupdate --all --install --force # 强制安装所有
Software Update Tool

Finding available software
Attempting to quit apps: (
    "com.apple.Compressor"
)
Successfully quit all apps

Downloading 专业视频格式
Downloaded 专业视频格式
Installing 专业视频格式
Done with 专业视频格式
Done.

忽略某个更新

比如忽略 JavaForOSX 更新

$ sudo softwareupdate --ignore JavaForOSX

重置忽略的更新

$ sudo softwareupdate --reset-ignored

关闭/开启 后台自动更新的检查

开启

$ sudo softwareupdate --schedule on

关闭

$ sudo softwareupdate --schedule off

查看下载安装进度

$ sudo softwareupdate -vi RAWCameraUpdate6.17-6.17

或者

sudo softwareupdate -v -i iTunesXPatch-12.3.1

查看更多选项

$ man softwareupdatesoftwareupdate -h

下载但不安装

$ sudo softwareupdate -d nameHere
$ sudo softwareupdate -d iTunesXPatch-12.3.1

取消下载

$ sudo softwareupdate -e

三、manual

softwareupdate(8) BSD System Manager’s Manual softwareupdate(8)

NAME

softwareupdate – system software update tool


SYNOPSIS

softwareupdate command [args …]


DESCRIPTION

Software Update checks for new and updated versions of your software based on information about your computer and current software.

Invoke softwareupdate by specifying a command followed by zero or more args.

softwareupdate requires admin authentication for all commands except –list.

​ If you run softwareupdate as a normal admin user, you will be prompted for a password where required.

​ Alternatively, you can run softwareupdate as root and avoid all further authentication prompts.


The following commands are available:


-l | –list
​ List all available updates.


-i | –install
​ Each update specified by args is downloaded and installed. args can be one of the following:

  • -r | --recommended
    ​ All updates that are recommended for your system. These are prefixed with a * character in the –list output.

  • -R | --restart
    ​ Automatically restart (or shut down) if required to complete installation. If the user invoking this tool is logged in then macOS will attempt to quit all applications, logout, and restart. If the user is not logged in, macOS will trigger a forced reboot if necessary. If you wish to always perform a forced reboot, pass -f (–force).

  • -a | --all All updates that are applicable to your system, including those non-recommended ones, which are prefixed with a - character in the –list output. (Non-recommended updates are uncommon in any case.)

  • item … One or more specified updates. The –list output shows the item names you can specify here, prefixed by the * or - characters. See EXAMPLES.


-d | –download
​ Each update specified by args is downloaded but not installed. The values of args are the same as for the –install command. Updates downloaded with –download can be subsequently installed with –install, or through the App Store (as long as they remain applicable to your system).
Updates are downloaded to /Library/Updates, but are not designed to be installed by double-clicking the packages in that directory: always use –install or the App Store to actually perform the install.


–schedule Returns the per-machine automatic (background) check preference.


-h | –help
​ Print command usage.


EXAMPLES

The following examples are shown as given to the shell:

 softwareupdate --list
 
​      Software Update Tool
 
​      Finding available software

​      Software Update found the following new or updated software:

​       * Label: MacBookAirEFIUpdate2.4-2.4

​          Title: MacBook Air EFI Firmware Update, Version: 2.4, Size: 3817K, Recommended: YES, Action: restart,

​       * Label: ProAppsQTCodecs-1.0

​          Title: ProApps QuickTime codecs, Version: 1.0, Size: 968K, Recommended: YES,

​       * Label: JavaForOSX-1.0

​          Title: Java for OS X 2012-005, Version: 1.0, Size: 65288K, Recommended: YES,


  sudo softwareupdate --install JavaForOSX-1.0



​      Software Update Tool 
​      Finding available software
 
​      Downloading Java for OS X 2012-005 
​      Downloaded Java for OS X 2012-005 
​      Installing Java for OS X 2012-005 
​      Done with Java for OS X 2012-005 
​      Done.

sudo softwareupdate --schedule
​ Automatic check is on

Mac OS September 11, 2012 Mac OS


相关资料


伊织 2021-03-09

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

编程乐园

请我喝杯伯爵奶茶~!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值