Ubuntu upgrade or update a single package using apt-get nixCraft

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


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 man page here for more info.

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

Facebook Comments

More Stuff

Adding an IP address to your Linux Server This is a quick guide on adding IPs to a system manually. I would only suggest it if you are not using a control panel, such as cpanel, that has a fea...
How to Upgrade Fedora 23 to Fedora 24 Workstation Fedora 24 general release was announced yesterday and many users are now hoping to upgrade to the latest edition of the popular Linux distribution. In...
Preparing server for bare metal restore using R1Soft Live Rescue C... Follow these steps to prepare a Linux or Windows server backup system, prodced by R1Soft,   for a bare metal restore. 1. Put the R1Soft Live...
Linux / Unix Find All The Files Owned By a Particular User / Group... How do I list or find all the files owned by a particular system user or group under Linux or UNIX like operating systems using command line options?...
Spread the love

Posted by News Monkey