Update software packages in Ubuntu
How To

How to Update Packages in Ubuntu

Sagar Sharma
Sagar Sharma

Table of Contents

Want to update packages on Ubuntu and have no idea how to do it?

To update all the upgradeable deb packages at once, you can use this combination of two commands:

sudo apt update && sudo apt upgrade -y

Want more details? Well, this guide will cover every aspect of how you can update packages on Ubuntu, which includes:

  • Updating the deb packages using apt
  • Updating the snap packages

So let's start with the first one.

How to update deb packages using apt on Ubuntu

If you don't know, Ubuntu is based on Debian, which uses the apt package manager to install, manage, and remove deb packages.

So there are 3 steps that you need to follow:

  1. Update system repository
  2. List the outdated packages
  3. Update one or multiple packages using the apt package manager

Let's start with the step 1.

Step 1: Update the system repository

Updating the system repository will update the repository index and fetch information about the latest packages available for your system.

To update the system repository, all you have to do is execute the simple command:

sudo apt update
Update system repository to update packages in Ubuntu

If an update is available for any package, it will show you the number of outdated packages and in my case, there are 32 outdated packages.

Step 2: List outdated packages

đź“‹
You can avoid this step if you want to update all the packages at once.

Once you update repositories and if it shows the number of outdated packages, you may want to list them if you only want to update the selective packages.

To list outdated packages, use the following command:

apt list --upgradable
List outdated deb packages using the apt to update packages in Ubuntu

Step 3: Update packages

This section is further divided into 2 parts:

  1. Update single package
  2. Update all the packages at once

So let's start with updating the single package.

Update single package using apt

🚧
Before updating a single package, make sure all the dependencies related to that package are updated or it may break the system entirely.

If you want to update only one package, then, you can use the apt in the following syntax:

sudo apt install --only-upgrade package-name

For example, if I want to update ufw, then, I will be using the following:

sudo apt install --only-upgrade ufw
Update single package only in Ubuntu

Update all the packages at once

If you wish to upgrade all the packages at once, then you can use the following command:

sudo apt upgrade 
Upgrade all the packages at once in Ubuntu

Simply type Y and it will start installing the listed packages.

How to update snap packages

Ubuntu comes pre-configured with snap packages, and it ships with some snap packages by default. In that case, using the apt package manager won't be useful.

The thing is, snaps are updated automatically as it is meant to be a convenient way of installing and managing packages on Ubuntu.

But that doesn't mean you can not update packages manually.

So in this section, I will walk you through how to list the outdated snap packages and how you can update them.

Step 1: List the outdated snap packages

To list the outdated snap packages, you can use the following command:

snap refresh --list
List outdated snap packages in Ubuntu

Step 2: Update outdated snap packages

đź’ˇ
To update all the snap packages at once, use: sudo snap refresh

If you want to update a specific package, then use the snap command in the following manner:

sudo snap refresh package_name

For example, if I want to update Firefox, then, I will be using the following:

sudo snap refresh firefox
Update snap package in Ubuntu

And if you want to update all the snap packages at once, then use the following command:

sudo snap refresh

Yep, that's all it takes to update snap packages.

Do more with snap updates

Did you know that you can revert to the old version of the snap package if the new version does not work as intended?

Also, you can keep packages from being updated!

Wanna know how? Here's a detailed guide on updating snap packages:

How to Update Snap Packages in Ubuntu
Snap packages are automatically updated. But you can still control the updates manually. Learn all about Snap updates here.

I hope you will find this guide helpful.



Sagar Sharma

Sagar Sharma

A software engineer who loves to tinker with hardware till it gets crashed. While reviving my crashed system, you can find me reading literature, manga, or watering my plants.