itsfosslinux

How to Update or Upgrade Packages on Ubuntu/Debian

In this article, we will see how to update or upgrade packages on Ubuntu/Debian. In Linux based systems, it is always recommended to update or upgrade system packages to the latest available versions. This can be done differently in different linux systems using their default package manager. For example on Ubuntu/Debian based systems, you can easily update or upgrade packages using apt or apt-get package manager. Similarly on RHEL/CentOS/Fedora based systems you can use yum or dnf package manager to update or upgrade system packages. Here we will mostly focus on steps to update or upgrade packages on Ubuntu/Debian based systems.

 

Why it is required

It is often taken very lightly but when it comes to stability, vulnerability and security of a linux system then the latest available package updates which provides bugfixes and hotfixes along with the important security patches can't be ignored. These are some critical components which can't be missed and has to be installed to hardened the system from any external attacks and broken dependencies. Almost all the linux flavors periodically releases package updates to deal with new system and application challenges. This updates needs to be regularly installed to make sure system remains stable and secure all the time.

 

How to Update or Upgrade Packages on Ubuntu/Debian

How to Update or Upgrade Packages on Ubuntu/Debian

Also Read: How to find files and directories in Linux

If you are looking to update your system package cache with all the latest package information from all the configured repo then run sudo apt update command as shown below.

itsfosslinux@ubuntu:~$ sudo apt update
[sudo] password for itsfosslinux:
Hit:1 https://dl.winehq.org/wine-builds/ubuntu focal InRelease
Hit:2 http://ppa.launchpad.net/flatpak/stable/ubuntu focal InRelease
Hit:3 https://dl.google.com/linux/chrome/deb stable InRelease
Hit:4 http://in.archive.ubuntu.com/ubuntu focal InRelease
Hit:5 https://download.sublimetext.com apt/stable/ InRelease
Hit:6 https://d3nt0h4h6pmmc4.cloudfront.net/ubuntu focal InRelease
Hit:7 http://ppa.launchpad.net/gencfsm/ppa/ubuntu focal InRelease
Get:8 https://repositories.timber.io/public/vector/deb/ubuntu focal InRelease [4,947 B]
Get:9 http://in.archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
Get:10 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]
Hit:11 https://ngrok-agent.s3.amazonaws.com buster InRelease
Hit:12 http://ppa.launchpad.net/juju/stable/ubuntu focal InRelease
Hit:13 http://ppa.launchpad.net/libreoffice/ppa/ubuntu focal InRelease
Ign:14 https://pkg.jenkins.io/debian-stable binary/ InRelease
Hit:15 https://pkg.jenkins.io/debian-stable binary/ Release
...............................................................

Then you can upgrade all packages to the latest available version by using sudo apt upgrade command as shown below.

itsfosslinux@ubuntu:~$ sudo apt upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
Get more security updates through Ubuntu Pro with 'esm-apps' enabled:
node-hosted-git-info python2.7-minimal python2.7 node-tar libgsasl7
libopusfile0 libsdl2-2.0-0 libsdl2-2.0-0 libpython2.7-minimal
libpython2.7-stdlib
Learn more about Ubuntu Pro at https://ubuntu.com/pro
#
# Canonical released microcode updates for both Intel (CVE-2022-40982) and AMD
# (CVE-2023-20593). ‘Unattended upgrades’ provide security updates by default.
# Ensure it remains enabled to always get all updates as they become available.
#
The following packages have been kept back:
xdg-desktop-portal xdg-desktop-portal-gtk
The following packages will be upgraded:
distro-info-data google-chrome-stable libssl-dev libssl1.1 libssl1.1:i386 openssl vim-common vim-tiny xserver-common xserver-xephyr xserver-xorg-core
xserver-xorg-legacy xwayland xxd
14 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.
12 standard LTS security updates
Need to get 113 MB of archives.
After this operation, 5,120 B of additional disk space will be used.
Do you want to continue? [Y/n] Y
.....................................................

To look for all the packages that needs to be upgraded, you can run sudo apt list --upgradable command as shown below.

itsfosslinux@ubuntu:~$ sudo apt list --upgradable
Listing... Done
distro-info-data/focal-updates,focal-updates 0.43ubuntu1.14 all [upgradable from: 0.43ubuntu1.13]
google-chrome-stable/stable 118.0.5993.117-1 amd64 [upgradable from: 118.0.5993.88-1]
libssl-dev/focal-updates,focal-security 1.1.1f-1ubuntu2.20 amd64 [upgradable from: 1.1.1f-1ubuntu2.19]
libssl1.1/focal-updates,focal-security 1.1.1f-1ubuntu2.20 amd64 [upgradable from: 1.1.1f-1ubuntu2.19]
libssl1.1/focal-updates,focal-security 1.1.1f-1ubuntu2.20 i386 [upgradable from: 1.1.1f-1ubuntu2.19]
openssl/focal-updates,focal-security 1.1.1f-1ubuntu2.20 amd64 [upgradable from: 1.1.1f-1ubuntu2.19]
vim-common/focal-updates,focal-updates,focal-security,focal-security 2:8.1.2269-1ubuntu5.20 all [upgradable from: 2:8.1.2269-1ubuntu5.18]
vim-tiny/focal-updates,focal-security 2:8.1.2269-1ubuntu5.20 amd64 [upgradable from: 2:8.1.2269-1ubuntu5.18]
xdg-desktop-portal-gtk/focal 1.8.0-1~flatpak1~20.04 amd64 [upgradable from: 1.6.0-1ubuntu1]
xdg-desktop-portal/focal 1.14.3-1~flatpak1~20.04 amd64 [upgradable from: 1.6.0-1ubuntu2]
xserver-common/focal-updates,focal-updates,focal-security,focal-security 2:1.20.13-1ubuntu1~20.04.9 all [upgradable from: 2:1.20.13-1ubuntu1~20.04.8]
xserver-xephyr/focal-updates,focal-security 2:1.20.13-1ubuntu1~20.04.9 amd64 [upgradable from: 2:1.20.13-1ubuntu1~20.04.8]
xserver-xorg-core/focal-updates,focal-security 2:1.20.13-1ubuntu1~20.04.9 amd64 [upgradable from: 2:1.20.13-1ubuntu1~20.04.8]
xserver-xorg-legacy/focal-updates,focal-security 2:1.20.13-1ubuntu1~20.04.9 amd64 [upgradable from: 2:1.20.13-1ubuntu1~20.04.8]
xwayland/focal-updates,focal-security 2:1.20.13-1ubuntu1~20.04.9 amd64 [upgradable from: 2:1.20.13-1ubuntu1~20.04.8]
xxd/focal-updates,focal-security 2:8.1.2269-1ubuntu5.20 amd64 [upgradable from: 2:8.1.2269-1ubuntu5.18]

You can also update and upgrade all the required packages to the latest version by using a single line command sudo apt update && sudo apt upgrade as shown below.

itsfosslinux@ubuntu:~$ sudo apt update && sudo apt upgrade
[sudo] password for itsfosslinux:
Hit:1 https://dl.google.com/linux/chrome/deb stable InRelease
Hit:2 https://d3nt0h4h6pmmc4.cloudfront.net/ubuntu focal InRelease
Ign:3 https://pkg.jenkins.io/debian-stable binary/ InRelease
Hit:4 https://pkg.jenkins.io/debian-stable binary/ Release
Hit:5 http://security.ubuntu.com/ubuntu focal-security InRelease
Hit:6 http://ppa.launchpad.net/flatpak/stable/ubuntu focal InRelease
Get:7 https://repositories.timber.io/public/vector/deb/ubuntu focal InRelease [4,947 B]
Hit:8 http://ppa.launchpad.net/gencfsm/ppa/ubuntu focal InRelease
Hit:9 http://in.archive.ubuntu.com/ubuntu focal InRelease
Hit:10 http://ppa.launchpad.net/juju/stable/ubuntu focal InRelease
Hit:11 https://download.sublimetext.com apt/stable/ InRelease
Get:12 http://in.archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
Hit:14 http://ppa.launchpad.net/libreoffice/ppa/ubuntu focal InRelease
Hit:15 https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/focal pgadmin4 InRelease
Hit:16 http://ppa.launchpad.net/mojo-maintainers/ppa/ubuntu focal InRelease
Hit:17 http://in.archive.ubuntu.com/ubuntu focal-backports InRelease
Hit:18 http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu focal InRelease
Hit:19 https://dl.winehq.org/wine-builds/ubuntu focal InRelease
Hit:20 https://ngrok-agent.s3.amazonaws.com buster InRelease
Fetched 119 kB in 7s (17.5 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
16 packages can be upgraded. Run 'apt list --upgradable' to see them.
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
Get more security updates through Ubuntu Pro with 'esm-apps' enabled:
node-hosted-git-info python2.7-minimal python2.7 node-tar libgsasl7
libopusfile0 libsdl2-2.0-0 libsdl2-2.0-0 libpython2.7-minimal
libpython2.7-stdlib
Learn more about Ubuntu Pro at https://ubuntu.com/pro
#
# Canonical released microcode updates for both Intel (CVE-2022-40982) and AMD
# (CVE-2023-20593). ‘Unattended upgrades’ provide security updates by default.
# Ensure it remains enabled to always get all updates as they become available.
#
The following packages have been kept back:
xdg-desktop-portal xdg-desktop-portal-gtk
The following packages will be upgraded:
distro-info-data google-chrome-stable libssl-dev libssl1.1 libssl1.1:i386 openssl vim-common vim-tiny xserver-common xserver-xephyr xserver-xorg-core
xserver-xorg-legacy xwayland xxd
.......................................................

You can also remove unwanted packages and install the packages which has been kept back by system to deal with the changing dependencies using sudo apt dist-upgrade command as shown below.

itsfosslinux@ubuntu:~$ sudo apt dist-upgrade
[sudo] password for itsfosslinux:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
Get more security updates through Ubuntu Pro with 'esm-apps' enabled:
node-hosted-git-info python2.7-minimal python2.7 node-tar libgsasl7
libopusfile0 libsdl2-2.0-0 libsdl2-2.0-0 libpython2.7-minimal
libpython2.7-stdlib
Learn more about Ubuntu Pro at https://ubuntu.com/pro
#
# Canonical released microcode updates for both Intel (CVE-2022-40982) and AMD
# (CVE-2023-20593). ‘Unattended upgrades’ provide security updates by default.
# Ensure it remains enabled to always get all updates as they become available.
#
The following packages have been kept back:
xdg-desktop-portal xdg-desktop-portal-gtk
The following packages will be upgraded:
distro-info-data google-chrome-stable libssl-dev libssl1.1 libssl1.1:i386 openssl vim-common vim-tiny xserver-common xserver-xephyr xserver-xorg-core
xserver-xorg-legacy xwayland xxd
14 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.
12 standard LTS security updates
Need to get 113 MB of archives.
After this operation, 5,120 B of additional disk space will be used.
Do you want to continue? [Y/n] Y
..............................................................

Instead of updating all the packages in the system if you are looking to apply only the important one such as security updates which are generally recommended to be installed then you have to perform unattended upgrade by using sudo apt install unattended-upgrades command as shown below.

itsfosslinux@ubuntu:~$ sudo apt install unattended-upgrades
Reading package lists... Done
Building dependency tree
Reading state information... Done
Suggested packages:
bsd-mailx needrestart
The following NEW packages will be installed:
unattended-upgrades
0 upgraded, 1 newly installed, 0 to remove and 16 not upgraded.
Need to get 48.5 kB of archives.
After this operation, 451 kB of additional disk space will be used.
Get:1 http://in.archive.ubuntu.com/ubuntu focal-updates/main amd64 unattended-upgrades all 2.3ubuntu0.3 [48.5 kB]
Fetched 48.5 kB in 1s (56.3 kB/s)
Preconfiguring packages ...
Selecting previously unselected package unattended-upgrades.
(Reading database ... 261605 files and directories currently installed.)
Preparing to unpack .../unattended-upgrades_2.3ubuntu0.3_all.deb ...
Unpacking unattended-upgrades (2.3ubuntu0.3) ...
Setting up unattended-upgrades (2.3ubuntu0.3) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for systemd (245.4-4ubuntu3.22) ...

If you are only looking to download the unattended-upgrades and does not really want to install them then use -d option with sudo apt install unattended-upgrades command as shown below.

itsfosslinux@ubuntu:~$ sudo apt install unattended-upgrades -d
Reading package lists... Done
Building dependency tree
Reading state information... Done
Suggested packages:
bsd-mailx needrestart
The following NEW packages will be installed:
unattended-upgrades
0 upgraded, 1 newly installed, 0 to remove and 16 not upgraded.
Need to get 48.5 kB of archives.
After this operation, 451 kB of additional disk space will be used.
Get:1 http://in.archive.ubuntu.com/ubuntu focal-updates/main amd64 unattended-upgrades all 2.3ubuntu0.3 [48.5 kB]
Fetched 48.5 kB in 1s (42.3 kB/s)
Download complete and in download only mode

Leave a comment