Checking for and Applying Virtual Machine Security Updates

Now we are logged into the virtual machine over SSH, we can switch to the root user and check for any security updates and apply those to make sure the VM is fully patched and up to date.

We can switch to root user with the following command:

vagrant@ubuntu-focal:~$ sudo su

Now we are root user with full administrator's rights,  we need to update the package management cache with:

root@ubuntu-focal:/home/vagrant# apt update
Get:1 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]
Hit:2 http://archive.ubuntu.com/ubuntu focal InRelease                           
Get:3 http://archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
...
Get:33 http://archive.ubuntu.com/ubuntu focal-backports/universe Translation-en [16.0 kB]
Get:34 http://archive.ubuntu.com/ubuntu focal-backports/universe amd64 c-n-f Metadata [860 B]
Get:35 http://archive.ubuntu.com/ubuntu focal-backports/multiverse amd64 c-n-f Metadata [116 B]
Fetched 21.1 MB in 7s (3225 kB/s) 
Reading package lists... Done
Building dependency tree        
Reading state information... Done
4 packages can be upgraded. Run 'apt list --upgradable' to see them.
root@ubuntu-focal:/home/vagrant#
root@ubuntu-focal:/home/vagrant# apt list --upgradable
Listing... Done
isc-dhcp-client/focal-updates,focal-security 4.4.1-2.1ubuntu5.20.04.4 amd64 [upgradable from: 4.4.1-2.1ubuntu5.20.04.3]
isc-dhcp-common/focal-updates,focal-security 4.4.1-2.1ubuntu5.20.04.4 amd64 [upgradable from: 4.4.1-2.1ubuntu5.20.04.3]
ubuntu-advantage-tools/focal-updates 27.11.2~20.04.1 amd64 [upgradable from: 27.10.1~20.04.1]
zlib1g/focal-updates 1:1.2.11.dfsg-2ubuntu1.4 amd64 [upgradable from: 1:1.2.11.dfsg-2ubuntu1.3]

To apply the above security updates do:

root@ubuntu-focal:/home/vagrant# apt upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
The following packages will be upgraded:
  isc-dhcp-client isc-dhcp-common ubuntu-advantage-tools zlib1g
4 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
2 standard security updates
Need to get 506 kB of archives.
After this operation, 112 kB of additional disk space will be used.
Do you want to continue? [Y/n]Y
Get:1 <a href="http://archive.ubuntu.com/ubuntu">http://archive.ubuntu.com/ubuntu</a> focal-updates/main amd64 zlib1g amd64 1:1.2.11.dfsg-2ubuntu1.4 [53.9 kB]
Get:2 <a href="http://archive.ubuntu.com/ubuntu">http://archive.ubuntu.com/ubuntu</a> focal-updates/main amd64 isc-dhcp-client amd64 4.4.1-2.1ubuntu5.20.04.4 [247 kB]
Get:3 <a href="http://archive.ubuntu.com/ubuntu">http://archive.ubuntu.com/ubuntu</a> focal-updates/main amd64 isc-dhcp-common amd64 4.4.1-2.1ubuntu5.20.04.4 [45.0 kB]
Get:4 <a href="http://archive.ubuntu.com/ubuntu">http://archive.ubuntu.com/ubuntu</a> focal-updates/main amd64 ubuntu-advantage-tools amd64 27.11.2~20.04.1 [160 kB]
Fetched 506 kB in 0s (3194 kB/s)
Preconfiguring packages ...
(Reading database ... 63504 files and directories currently installed.)
Preparing to unpack .../zlib1g_1%3a1.2.11.dfsg-2ubuntu1.4_amd64.deb ...
Unpacking zlib1g:amd64 (1:1.2.11.dfsg-2ubuntu1.4) over (1:1.2.11.dfsg-2ubuntu1.3) ...
Setting up zlib1g:amd64 (1:1.2.11.dfsg-2ubuntu1.4) ...
(Reading database ... 63504 files and directories currently installed.)
Preparing to unpack .../isc-dhcp-client_4.4.1-2.1ubuntu5.20.04.4_amd64.deb ...
Unpacking isc-dhcp-client (4.4.1-2.1ubuntu5.20.04.4) over (4.4.1-2.1ubuntu5.20.04.3) ...
Preparing to unpack .../isc-dhcp-common_4.4.1-2.1ubuntu5.20.04.4_amd64.deb ...
Unpacking isc-dhcp-common (4.4.1-2.1ubuntu5.20.04.4) over (4.4.1-2.1ubuntu5.20.04.3) ...
Preparing to unpack .../ubuntu-advantage-tools_27.11.2~20.04.1_amd64.deb ...
Unpacking ubuntu-advantage-tools (27.11.2~20.04.1) over (27.10.1~20.04.1) ...
Setting up isc-dhcp-client (4.4.1-2.1ubuntu5.20.04.4) ...
Setting up isc-dhcp-common (4.4.1-2.1ubuntu5.20.04.4) ...
Setting up ubuntu-advantage-tools (27.11.2~20.04.1) ...
Installing new version of config file /etc/ubuntu-advantage/help_data.yaml ...
Installing new version of config file /etc/ubuntu-advantage/uaclient.conf ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for libc-bin (2.31-0ubuntu9.9) ...
root@ubuntu-focal:/home/vagrant#

Now if we run the apt update command again, we can see that all packages are now up to date:

root@ubuntu-focal:/home/vagrant# apt update
Hit:1 <a href="http://archive.ubuntu.com/ubuntu">http://archive.ubuntu.com/ubuntu</a> focal InRelease
Hit:2 <a href="http://archive.ubuntu.com/ubuntu">http://archive.ubuntu.com/ubuntu</a> focal-updates InRelease
Hit:3 <a href="http://archive.ubuntu.com/ubuntu">http://archive.ubuntu.com/ubuntu</a> focal-backports InRelease
Hit:4 <a href="http://security.ubuntu.com/ubuntu">http://security.ubuntu.com/ubuntu</a> focal-security InRelease
Reading package lists... Done
Building dependency tree
Reading state information... Done
All packages are up to date.
root@ubuntu-focal:/home/vagrant#