Upgrade a Single package on Ubuntu

|
Last Updated:
|
|
Upgrade a Single package on Ubuntu

Follow through this guide to learn how to upgrade a single package on Ubuntu.

Upgrading a Single package on Ubuntu

Ubuntu and other Debian derivatives provides commands such as apt upgrade for upgrading the system packages.

According to APT man pages, man apt;

apt 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 removal of an installed package the upgrade for this package isn’t performed.

In order to install a package in Ubuntu, you would usually run the command;

apt install <packagename>

Where <packagename> is the name of the package in question.

So upgrading a single package on Ubuntu, you would pass yet another option, --only-upgrade to the apt install command such that your command looks like;

apt install --only-upgrade <packagename>

Note that the package ought to have already been installed.

For example, let us list the packages that can be upgraded on my Ubuntu 20.04 system;

apt list --upgradable
Listing... Done
firefox-locale-en/focal-updates,focal-security 85.0+build1-0ubuntu0.20.04.1 amd64 [upgradable from: 84.0.2+build1-0ubuntu0.20.04.1]
firefox/focal-updates,focal-security 85.0+build1-0ubuntu0.20.04.1 amd64 [upgradable from: 84.0.2+build1-0ubuntu0.20.04.1]
libmysqlclient21/focal-updates,focal-security 8.0.23-0ubuntu0.20.04.1 amd64 [upgradable from: 8.0.22-0ubuntu0.20.04.3]
skypeforlinux/stable 8.68.0.100 amd64 [upgradable from: 8.67.0.96]
ubuntu-drivers-common/focal-updates 1:0.8.6.4~0.20.04.1 amd64 [upgradable from: 1:0.8.6.3~0.20.04.2]

As you can see, I have some packages that can be upgraded.

NOTE: if i run apt upgrade, all these packages will be marked for upgrade;

apt upgrade
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
The following package was automatically installed and is no longer required:
  libllvm10
Use 'sudo apt autoremove' to remove it.
The following packages will be upgraded:
  firefox firefox-locale-en libmysqlclient21 skypeforlinux ubuntu-drivers-common
5 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 141 MB of archives.
After this operation, 2,381 kB disk space will be freed.
Do you want to continue? [Y/n]

Update the package cache;

apt update

Then, upgrade a single package using the apt install --only-upgrade command.

For example, If i want to upgrade only skypeforlinux package as per my output of the list of upgradable packages;

apt install --only-upgrade skypeforlinux
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following package was automatically installed and is no longer required:
  libllvm10
Use 'sudo apt autoremove' to remove it.
The following packages will be upgraded:
  skypeforlinux
1 upgraded, 0 newly installed, 0 to remove and 9 not upgraded.
Need to get 83.1 MB of archives.
After this operation, 2,857 kB disk space will be freed.
Get:1 https://repo.skype.com/deb stable/main amd64 skypeforlinux amd64 8.68.0.100 [83.1 MB]

As a side note, if you want to install or upgrade a package and at the same time you need to remove packages that are no longer required, pass the --auto-remove option.

for example;

apt install --only-upgrade skypeforlinux --auto-remove

You would achieve the same y running the command;

apt autoremove

Further Reading

Consult APT man pages for detailed information on using it.

man apt

SUPPORT US VIA A VIRTUAL CUP OF COFFEE

We're passionate about sharing our knowledge and experiences with you through our blog. If you appreciate our efforts, consider buying us a virtual coffee. Your support keeps us motivated and enables us to continually improve, ensuring that we can provide you with the best content possible. Thank you for being a coffee-fueled champion of our work!

Photo of author
gen_too
Co-founder of Kifarunix.com, Linux Tips and Tutorials. Linux/Unix admin and author at Kifarunix.com.

Leave a Comment