Ubuntu upgrade or update a single package using apt-get

I am a new Ubuntu Linux server system administrator. I need to upgrade or update a single package using apt-get command or apt command. How do I update a specific package in Ubuntu Linux? How do I upgrade a single package using apt-get?

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:

  1. Open the Terminal application
  2. Fetch package index by running sudo apt update command
  3. Now only update apache2 package by running sudo apt install apache2 command.
  4. 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

Ubuntu upgrade or update a single package using apt-get


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:
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

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 1 comment so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersncdu pydf
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
1 comment… add one
  • Rob4Winter May 13, 2019 @ 18:51

    To upgrade a single package using apt-get and apt command:
    # apt update
    # apt --only-upgrade install pkg1
    # apt-get --only-upgrade bash

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum