getting ubuntu up to date - enveng-group/enviroBI GitHub Wiki

Getting Ubuntu Up to Date

Now that the Ubuntu Pro subscription is attached, this guide will walk you through the steps to update your Ubuntu system to ensure it is up to date with the latest security patches and software updates.

Steps to Update Ubuntu

  1. Connect to your Ubuntu instance:

    Use SSH to connect to your Ubuntu instance. Replace <YOUR_EC2_INSTANCE_IP> with the public IP address of your Ubuntu instance.

    ssh -i /path/to/your-key.pem ubuntu@<YOUR_EC2_INSTANCE_IP>
    
  2. To ensure change are not overwritten by cloud-init, you can add the following line to the /etc/cloud/cloud.cfg:

apt_preserve_sources_list: true
  1. Modify the template file used by cloud-init to update the sources list. This will ensure that the sources list is updated when the instance is launched.
sudo micro /etc/cloud/templates/sources.list.ubuntu.deb822.tmpl
  1. Update the sources.list.ubuntu.deb822.tmpl file to include only the main and restricted components:
# Written by ubuntu-pro-client
Types: deb
URIs: {{mirror}}
Suites: {{codename}} {{codename}}-updates
Components: main restricted universe
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg

## Ubuntu security updates. Aside from URIs and Suites,
## this should mirror your choices in the previous section.
Types: deb
URIs: {{security}}
Suites: {{codename}}-security
Components: main restricted universe
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
  1. Update ubuntu.sources in /etc/apt/sources.list.d/ directory to use only the main, universe and restricted components and remove the backports suite:
sudo micro /etc/apt/sources.list.d/ubuntu.sources

Update the Components lines to include only main, universe and restricted and remove the backports suite:

Types: deb
URIs: http://ap-southeast-2-per-1a.clouds.archive.ubuntu.com/ubuntu/
Suites: noble noble-updates
Components: main restricted universe
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg

## Ubuntu security updates. Aside from URIs and Suites,
## this should mirror your choices in the previous section.
Types: deb
URIs: http://security.ubuntu.com/ubuntu
Suites: noble-security
Components: main restricted universe
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg" > /etc/apt/sources.list.d/ubuntu.sources'
  1. Navigate to the /etc/apt/sources.list.d/ directory and edit the ubuntu.esm-apps.sources file to use only the main components and add the noble-apps-updates suite.
# Written by ubuntu-pro-client
Types: deb
URIs: https://esm.ubuntu.com/apps/ubuntu
Suites: noble-apps-security noble-apps-updates
Components: main
Signed-By: /usr/share/keyrings/ubuntu-pro-esm-apps.gpg
  1. Navigate to the /etc/apt/sources.list.d/ directory and edit the ubuntu.esm-infra.sources file to use only the main components and add the noble-infra-updates suite.
# Written by ubuntu-pro-client
Types: deb
URIs: https://esm.ubuntu.com/infra/ubuntu
Suites: noble-infra-security noble-infra-updates
Components: main
Signed-By: /usr/share/keyrings/ubuntu-pro-esm-infra.gpg
  1. Update the package list:

It's a good practice to update the package list before making any changes.

sudo apt update
  1. Upgrade installed packages:

Once the package list is updated, you can upgrade the installed packages to the latest versions.

sudo apt full-upgrade -y

If prompted to confirm the upgrade, type Y and press Enter.

  1. Remove unnecessary packages:

After upgrading, remove packages that are no longer needed.

sudo apt autoremove
  1. Clean up the package cache:

Clean up the local repository of retrieved package files.

sudo apt autoclean
  1. Refresh Snap packages:

Ensure all Snap packages are up to date.

sudo snap refresh
  1. Reboot the system:

After upgrading the packages, cleaning up, and refreshing Snap packages, reboot the system to ensure all updates are applied.

sudo reboot