何時運行“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/或兩者都使用。請注意,升級軟體包本身可能會帶來一些困難。

相關內容