何时运行“sudo apt update”,何时运行“sudo apt update && sudo apt upgrade”?

何时运行“sudo apt update”,何时运行“sudo apt update && sudo apt upgrade”?

据我记得,我总是在安装新包之前运行sudo apt update或。sudo apt-get update

我什么时候应该跑步updateupgrade像这样:

sudo apt update && sudo apt upgrade

答案1

您运行sudo apt update以刷新可用包的列表。

您运行sudo apt upgrade以升级所有已安装的软件包。

显然,您总是update先运行upgrade以使用最新列表。

答案2

... update部分更新可用软件包的库,以便您的系统知道哪些是可用的,并可以将它们与已安装的软件包进行比较。

从存储库中获取... upgrade软件包,并安装或“升级”软件包。

假设只有在有需要升级的软件包时才需要... upgrade,但是如果没有可升级的软件包,apt则会退出而不会出现错误。

答案3

我认为手册页解释得很好:

   update (apt-get(8))
       update is used to download package information from all configured
       sources. Other commands operate on this data to e.g. perform
       package upgrades or search in and display details about all
       packages available for installation.

   upgrade (apt-get(8))
       upgrade is used to install available upgrades of all packages
       currently installed on the system from the sources configured via
       sources.list(5). New packages will be installed if required to
       satisfy dependencies, but existing packages will never be removed.
       If an upgrade for a package requires the remove of an installed
       package the upgrade for this package isn't performed.

因此,根据您的需要,您可能希望使用updateupgrade或两者兼而有之。请注意,升级软件包本身可能会带来一些困难。

相关内容