在 Ubuntu 上安裝我們運行的包的更新版本 apt-get update
其次是 apt-get upgrade
命令。 這將更新所有已安裝的軟件包,這些軟件包在存儲庫中具有可用的新版本。
在某些情況下,我們只需要升級一個 單包 比如PHP, Apache 或 Nginx。
在 Ubuntu 中升級單個包
升級特定的包運行 sudo apt install package-name
.
第一的 獲取更新的包列表,但它不會安裝或更新軟件包:
$ sudo apt update
以下命令將 更新包 如果已經安裝了 gimp:
$ sudo apt install gimp
輸出
Reading package lists… Done
Building dependency tree
Reading state information… Done
gimp is already the newest version (2.10.18-1).
0 upgraded, 0 newly installed, 0 to remove and 101 not upgraded.
注意:您可以使用相同的命令進行全新的軟件包安裝,也可以更新到較新的版本。
使用 –only-upgrade 升級特定包
升級 單個或特定包 利用 --only-upgrade
選項。 這裡與上述方法的不同之處在於,如果軟件包尚未安裝,則不會更新。
以下命令升級 gimp 包:
$ sudo apt-get --only-upgrade install gimp
輸出
Reading package lists… Done
Building dependency tree
Reading state information… Done
gimp is already the newest version (2.10.18-1).
0 upgraded, 0 newly installed, 0 to remove and 101 not upgraded.
讓我們看看,如果包不存在,輸出會是什麼樣子:
$ sudo apt-get --only-upgrade install krita
從輸出中您可以看到它的 跳過 升級是因為沒有安裝 krita 包。
Reading package lists… Done
Building dependency tree
Reading state information… Done
Skipping krita, it is not installed and only upgrades are requested.
0 upgraded, 0 newly installed, 0 to remove and 101 not upgraded.
結論
在本教程中,我們學習瞭如何在 Ubuntu 上升級單個軟件包。 也可以從 apt-get upgrade 中排除特定的包。
欲了解更多信息,請訪問 apt/apt-get 手冊頁。 感謝閱讀,請留下您的評論。