Finding and installing the security updates on Ubuntu

Keeping the system updated is a daily task of sys admins. To find out the available security updates on a Ubuntu machine use the commands here under. I have done this on a virtual machine Ubuntu 21.04.

apt update

This will update all the package information for the Debian repositories.

grep security /etc/apt/sources.list > /tmp/security.list

Getting the security repositories so we can only check in those. The apt software repositories are defined in the /etc/apt/sources.list file or in separate files under the /etc/apt/sources.list.d/ directory in
Ubuntu and all other Debian based distributions.

Finding and installing the security updates in Ubuntu

sudo apt list --upgradable -oDir::Etc::Sourcelist=/tmp/security.list
Listing... Done
libperl5.32/hirsute-security 5.32.1-3ubuntu2.1 amd64 [upgradable from: 5.32.1-3ubuntu2]
perl-base/hirsute-security 5.32.1-3ubuntu2.1 amd64 [upgradable from: 5.32.1-3ubuntu2]
perl-modules-5.32/hirsute-security 5.32.1-3ubuntu2.1 all [upgradable from: 5.32.1-3ubuntu2]
perl/hirsute-security 5.32.1-3ubuntu2.1 amd64 [upgradable from: 5.32.1-3ubuntu2]

Installing the security upgrades

The next step is to install the security upgrades.

sudo apt-get upgrade -oDir::Etc::Sourcelist=/tmp/security.list -s
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Calculating upgrade... Done
The following packages will be upgraded:
  libperl5.32 perl perl-base perl-modules-5.32
4 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Inst libperl5.32 [5.32.1-3ubuntu2] (5.32.1-3ubuntu2.1 Ubuntu:21.04/hirsute-security [amd64]) [perl:amd64 ]
Inst perl [5.32.1-3ubuntu2] (5.32.1-3ubuntu2.1 Ubuntu:21.04/hirsute-security [amd64]) []
Inst perl-base [5.32.1-3ubuntu2] (5.32.1-3ubuntu2.1 Ubuntu:21.04/hirsute-security [amd64]) []
Conf perl-base (5.32.1-3ubuntu2.1 Ubuntu:21.04/hirsute-security [amd64]) []
Inst perl-modules-5.32 [5.32.1-3ubuntu2] (5.32.1-3ubuntu2.1 Ubuntu:21.04/hirsute-security [all])
Conf libperl5.32 (5.32.1-3ubuntu2.1 Ubuntu:21.04/hirsute-security [amd64])
Conf perl (5.32.1-3ubuntu2.1 Ubuntu:21.04/hirsute-security [amd64])
Conf perl-modules-5.32 (5.32.1-3ubuntu2.1 Ubuntu:21.04/hirsute-security [all])

Stay safe and keep the system secured.