如何使用命令行软件更新工具更新Apple OS X

时间:2020-01-09 10:37:11  来源:igfitidea点击:

如何在Apple Mac OS X计算机上通过命令行工具安装软件更新?
如何仅通过插入系统即可远程更新Apple计算机?

Apple OS X是否有类似apt-get命令或yum命令的内容?
您需要使用softwareupdate命令根据有关Apple Mac计算机和当前软件的信息来检查软件的新版本和更新版本。
此命令需要所有命令的管理员身份验证,即您需要使用sudo工具运行它。
在本教程中,您将学习如何在Mac OS X上从bash命令行安装软件更新。

如何找到所有可用的更新?

打开终端应用程序,然后键入以下命令。
键入以下命令:

softwareupdate -l

要么

softwareupdate --list

输出示例:列出所有可用更新

从上面的更新中,我们得到如下列表:

* RAWCameraUpdate6.17-6.17
	Digital Camera RAW Compatibility Update (6.17), 7455K [recommended]

其中:

  • RAWCameraUpdate6.17-6.17是可用于更新的软件,也称为标识符。
  • 版本号6.17
  • 7455k下载大小
  • 请注意,需要重启的更新标有[restart]。

如何安装指定的更新?

要安装名为RAWCameraUpdate6.17-6.17的更新,请输入:

sudo softwareupdate -i RAWCameraUpdate6.17-6.17

输出示例:

Password:
Software Update Tool
Copyright 2002-2015 Apple Inc.
 
 
Downloading Digital Camera RAW Compatibility Update
Downloaded Digital Camera RAW Compatibility Update
Installing Digital Camera RAW Compatibility Update
Done with Digital Camera RAW Compatibility Update
Done.

关于使用空格处理更新名称的说明

某些更新名称可能包含空格,请使用单引号将更新名称括起来,如下所示:

sudo softwareupdate -i 'OS X El Capitan Update-10.11.1'

我如何查看软件下载和更新进度?

通过-v选项,如下所示:

sudo softwareupdate -vi RAWCameraUpdate6.17-6.17

要么

sudo softwareupdate -v -i iTunesXPatch-12.3.1

输出示例:

Software Update Tool
Copyright 2002-2015 Apple Inc.
 
 
Downloading iTunes
   Progress: 1%
   Progress: 2%
   Progress: 3%
   Progress: 4%
   Progress: 5%
   Progress: 6%
   Progress: 7%
   Progress: 8%
   Progress: 9%
   Progress: 10%
   ....
   ..
   ...
   Progress: 48%
   Progress: 49%
Downloaded iTunes
Installing iTunes
   Progress: 51%
   Progress: 53%
   Progress: 54%
   Progress: 56%
   Progress: 57%
....
..
..
   Progress: 97%
   Progress: 99%
Done with iTunes
Done.

如何仅下载更新但不安装在系统上?

使用以下语法:

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

要取消下载,请输入:

sudo softwareupdate -e

如何应用所有推荐的更新?

建议您的系统使用的所有更新:

sudo softwareupdate -r

要安装适用于您的系统的所有更新,请输入:

sudo softwareupdate -i -a

安装所有程序,但确保忽略JavaForOSX更新:

sudo softwareupdate --ignore JavaForOSX

要清除列表中忽略的更新,请输入:

sudo softwareupdate --reset-ignored

打开或关闭自动背景检查

自动检查已启用

sudo softwareupdate --schedule on

自动检查已关闭

sudo softwareupdate --schedule off

要查看所有选项的信息,请键入:

man softwareupdate
softwareupdate -h

输出示例:

usage: softwareupdate <mode> [<args> ...]
 
** Catalog Management:
	--set-catalog <URL>	Set the new catalog URL (requires privileges)
	--clear-catalog		Clear the catalog URL back to defaults (requires privileges)
 
** Manage Updates:
	-l | --list		List all appropriate update labels (options:  --no-scan)
	-d | --download		Download Only
	-e | --cancel-download		Cancel a download
	-i | --install		Install
		<label> ...	specific updates
		-a | --all		All appropriate updates
		-r | --recommended	Only recommended updates
	--background		Trigger a background scan and update operation
	--ignore <label> ...	Ignore specific updates
	--reset-ignored		Clear all ignored updates
 
** Other Tools:
	--suspend-background (on | off)	Suspend background operations from occurring temporarily (uses --duration)
		--duration <duration>)		Optional duration in seconds to suspend background operations (defaults to 5*60 seconds)
	--dump-state		Log the internal state of the SU daemon to /var/log/install.log
** Options:
	--no-scan		Do not scan when listing or installing updates (use available updates previously scanned)
 
-v | --verbose	Enable verbose output
-h | --help	Print this help