What sudo apt update and upgrade Do on Ubuntu / Debian

In this guide, we want to teach you What sudo apt update and upgrade Do on Ubuntu / Debian. As you may know, APT is the default package manager for Ubuntu and Debian distributions. It is used for package management processes such as installing, updating, and removing a package. There are two most useful commands in Debian-based distros which are sudo apt update and sudo apt upgrade. Before you start doing your tasks on your server, you use these two commands to keep your system up to date.

Now follow the steps below to discuss the differences between sudo apt update and upgrade and what they exactly do on Ubuntu / Debian.

Note: Also, you may want to use apt-get instead of apt. You can visit this guide on apt vs apt-get – Which One Should We Use, to understand the differences.

What sudo apt update and upgrade Do on Ubuntu / Debian

For many users, sudo apt update and upgrade are the same and they have the same job. But, they are not the same and their functionality is different from each other. Follow the rest of the article to discuss the differences and what they do on Ubuntu and Debian distros.

Step 1 – What Is the Difference Between sudo apt update and sudo apt upgrade?

First, you must know that sudo is used for the users with root privileges. The non-root users with sudo privileges can do the root tasks.

Then, let’s discuss the main difference between sudo apt update and sudo apt update.

The sudo apt update brings the latest versions of the packages from the default Debian and Ubuntu repositories. It will find out the latest packages and dependencies, but it doesn’t download and install them.

On the other hand, the sudo apt upgrade will download and install the latest packages and dependencies.

Step 2 – Usage of sudo apt update and sudo apt upgrade Comamnds on Ubuntu / Debian

At this point, we want to show you how to use these commands. For example, we run the sudo apt update command on Ubuntu 22.04 as follows:

sudo apt update

We get the following output:

Output
Hit:1 http://de.archive.ubuntu.com/ubuntu jammy InRelease
Get:2 http://de.archive.ubuntu.com/ubuntu jammy-updates InRelease [119 kB]
Get:3 http://de.archive.ubuntu.com/ubuntu jammy-backports InRelease [109 kB]
Get:4 http://de.archive.ubuntu.com/ubuntu jammy-security InRelease [110 kB]
Get:5 http://de.archive.ubuntu.com/ubuntu jammy-updates/main amd64 Packages [970 kB]
Get:6 http://de.archive.ubuntu.com/ubuntu jammy-updates/universe amd64 Packages [979 kB]
Fetched 2,286 kB in 1s (1,913 kB/s)
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
193 packages can be upgraded. Run 'apt list --upgradable' to see them.

As you can see from the output, it fetches the updated packages and we have 193 packages that can be upgraded.

To list our upgradable packages, we run the command below:

sudo apt list --upgradable

This command will bring you a list of upgradable packages:

Output
Listing... Done
amd64-microcode/jammy-updates,jammy-security 3.20191218.1ubuntu2.2 amd64 [upgradable from: 3.20191218.1ubuntu2]
apparmor/jammy-updates 3.0.4-2ubuntu2.2 amd64 [upgradable from: 3.0.4-2ubuntu2.1]
apport/jammy-updates 2.20.11-0ubuntu82.5 all [upgradable from: 2.20.11-0ubuntu82.1]
apt-utils/jammy-updates 2.4.10 amd64 [upgradable from: 2.4.6]
apt/jammy-updates 2.4.10 amd64 [upgradable from: 2.4.6]
base-files/jammy-updates 12ubuntu4.4 amd64 [upgradable from: 12ubuntu4.2]
bind9-dnsutils/jammy-updates,jammy-security 1:9.18.12-0ubuntu0.22.04.2 amd64 [upgradable from: 1:9.18.1-1ubuntu1.1]
....

Now you can easily use the sudo apt upgrade to download and install the new packages and dependencies on Ubuntu / Debian:

sudo apt upgrade
Output
...
193 upgraded, 7 newly installed, 0 to remove and 0 not upgraded.
96 standard security updates
Need to get 484 MB of archives.
After this operation, 732 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y

To continue the upgrade process enter Y.

This will download and install the latest packages available on your Debian and Ubuntu distros. Also, it may take some time to complete depending on the upgradable packages.

When it is completed, you will get the following output:

Output
done
Scanning processes...
Scanning candidates...
Scanning linux images...
...

Also, the sudo apt upgrade command will not remove the old dependencies. To remove the old packages and unnecessary dependencies, you can use the command below:

sudo apt autoremove
Output
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages will be REMOVED:
  libflashrom1 libftdi1-2 linux-headers-5.15.0-43
  linux-headers-5.15.0-43-generic linux-image-5.15.0-43-generic
  linux-modules-5.15.0-43-generic linux-modules-extra-5.15.0-43-generic
0 upgraded, 0 newly installed, 7 to remove and 0 not upgraded.
After this operation, 562 MB disk space will be freed.
Do you want to continue? [Y/n] Y

Press Y to free the disk space by removing the unwanted packages.

Conclusion

At this point, you have learned What sudo apt update and upgrade Do on Ubuntu / Debian. These two commands are the most useful commands on the Debian-based distros and can be used to fetch and install the new packages available in the default repository.

Hope you enjoy it. For more guides and articles, you can visit the Orcacore website.

Also, you may be interested in these articles:

Disable NTP Network Time Synchronization on Ubuntu

Using the ssh-copy-id Command

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Stay informed and not overwhelmed, subscribe now!