Introduction: By default when you run either ‘apt-get upgrade’ or ‘apt upgrade’, Ubuntu will update all installed packages. However, in some cases, you may want to upgrade a specific package only such as Apache or Nginx. It is also possible to blacklist upgrading packages on Ubuntu Linux. As an Ubuntu Linux system administrator, you have full control over package management.
How to Ubuntu upgrade or update a single package
The procedure to update a a specific package on Ubuntu:
- Open the Terminal application
- Fetch package index by running sudo apt update command
- Now only update apache2 package by running sudo apt install apache2 command.
- If apache2 package already installed it will try to update to the latest version. If you do not want to install new packages; when used in conjunction with install, only-upgrade will install upgrades for already installed packages only and ignore requests to install new packages. Try sudo apt --only-upgrade install apache2
Let us see all commands and examples in details.
How to upgrade a single package using apt-get?
As usual you need to fetch an updated index from the Internet:
$ sudo apt-get update
You need to use following format with the apt-get command/apt command:
$ sudo apt-get --only-upgrade install Package
$ sudo apt-get install Package
Let us try to upgrade nginx web server:
$ sudo apt-get install nginx
If nginx package is already installed it will try to update to latest version:
Reading package lists... Done Building dependency tree Reading state information... Done nginx is already the newest version (1.10.3-0ubuntu0.16.04.2). 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
However, the following will not install a new nginx package if not installed:
$ sudo apt-get --only-upgrade install nginx
In this following example, htop is installed and I am requesting update. However, atop not installed and I am still requesting an update for it:
$ sudo apt-get install htop
$ sudo apt-get --only-upgrade install atop
First, download package information from all configured source:
$ sudo apt-get update
Run the to see availble updates:
$ sudo apt list --upgradable
Listing... Done apport-gtk/focal-security,focal-security 2.20.11-0ubuntu27.6 all [upgradable from: 2.20.11-0ubuntu27.4] apport/focal-security,focal-security 2.20.11-0ubuntu27.6 all [upgradable from: 2.20.11-0ubuntu27.4] libssh-4/focal-updates,focal-security 0.9.3-2ubuntu2.1 amd64 [upgradable from: 0.9.3-2ubuntu2] libssh-gcrypt-4/focal-updates,focal-security 0.9.3-2ubuntu2.1 amd64 [upgradable from: 0.9.3-2ubuntu2] libwhoopsie0/focal-security 0.2.69ubuntu0.1 amd64 [upgradable from: 0.2.69] ppp/focal-security 2.4.7-2+4.1ubuntu5.1 amd64 [upgradable from: 2.4.7-2+4.1ubuntu5] python3-apport/focal-security,focal-security 2.20.11-0ubuntu27.6 all [upgradable from: 2.20.11-0ubuntu27.4] python3-problem-report/focal-security,focal-security 2.20.11-0ubuntu27.6 all [upgradable from: 2.20.11-0ubuntu27.4] whoopsie/focal-security 0.2.69ubuntu0.1 amd64 [upgradable from: 0.2.69]
We have 9 updates available but we are just going to update ppp package:
$ sudo apt-get --only-upgrade install ppp
## OR ##
$ sudo apt --only-upgrade install ppp
Reading package lists... Done Building dependency tree Reading state information... Done The following packages will be upgraded: ppp 1 upgraded, 0 newly installed, 0 to remove and 8 not upgraded. Need to get 328 kB of archives. After this operation, 0 B of additional disk space will be used. Get:1 http://security.ubuntu.com/ubuntu focal-security/main amd64 ppp amd64 2.4.7-2+4.1ubuntu5.1 [328 kB] Fetched 199 kB in 2s (123 kB/s) (Reading database ... 288234 files and directories currently installed.) Preparing to unpack .../ppp_2.4.7-2+4.1ubuntu5.1_amd64.deb ... Unpacking ppp (2.4.7-2+4.1ubuntu5.1) over (2.4.7-2+4.1ubuntu5) ... Setting up ppp (2.4.7-2+4.1ubuntu5.1) ... Processing triggers for systemd (245.4-4ubuntu3.2) ... Processing triggers for man-db (2.9.1-1) ... Processing triggers for libc-bin (2.31-0ubuntu9) ...
You learned how to update a specific package on Ubuntu Linux. Please note that you need to pass the --only-upgrade to the apt command when you only want that single package upgrade provided that it is installed. See apt/apt-get man page online here for more information or type the following man command:
$ man apt
$ man apt-get
🐧 1 comment so far... add one ↓
|Category||List of Unix and Linux commands|
|Disk space analyzers||ncdu • pydf|
|Firewall||Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04|
|Network Utilities||NetHogs • dig • host • ip • nmap|
|OpenVPN||CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04|
|Package Manager||apk • apt|
|Processes Management||bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time|
|Searching||grep • whereis • which|
|User Information||groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w|
|WireGuard VPN||Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04|