how to upgrade ubuntu from terminal code example

Example 1: update ubuntu

sudo apt update && sudo apt upgrade -y
#or use it seperately
sudo apt update
sudo apt upgrade
#you make wanna run below command to remove unwanted
#and free up some space
sudo apt autoremove

Example 2: update ubuntu in terminal

#gets package(s) update definitions
sudo apt update
#upgrades the package(s) for which update definitions are received
sudo apt upgrade

Example 3: upgrade ubuntu command line

sudo apt update
sudo apt upgrade