How to Upgrade a Single Package with apt on Ubuntu/Debian

The apt upgrade command, as you may already know, is used to upgrade packages to their latest versions on Ubuntu and Debian-based Linux distributions.

The apt upgrade command upgrades all packages—it can't be used to upgrade just a single package.

If you want to upgrade a single package, you need to use the apt install command with the --only-upgrade option:

sudo apt install --only-upgrade package-name

You can also upgrade multiple packages at once using the --only-upgrade option:

sudo apt install --only-upgrade package1 package2

Example

sudo apt install --only-upgrade apache2

The above command updates the Apache2 web server and its dependency packages, if updates are available.