How to update installed Ubuntu packages using terminal

You have installed Ubuntu but you also need to update the packages periodically. Let us see quick and easy commands to update the packages within your Ubuntu installation.
This post tries to capture the steps that I needed to update Ubuntu 23.04 running on a VPS. The same set of steps can be used to update your Ubuntu machine either be it a physical device or a cloud instance.
5 beginner-friendly steps to update Ubuntu packages using the terminal
Advanced Packaging Tool (APT) is a package management tool in Debian Linux flavors including Ubuntu. apt-get is a part of the apt CLI tool for handling packages in Debian systems.
SSH to your server and follow the steps mentioned below:
Fetch the latest updates for packages installed in the system
sudo apt-get update
Download and install the updates in one go
sudo apt-get upgrade
Remove stale packages that are no longer needed
sudo apt-get autoremove
Cleans the packages and install script in /var/cache/apt/archives/
sudo apt-get clean
Once you are comfortable with the above four individual steps to update your Ubuntu installation, you can then use the below command to run all of them in one go. To bypass the yes/no prompt you can append the -y flag.
sudo apt-get update && sudo apt-get upgrade -y && sudo apt-get autoremove -y && sudo apt-get clean -y