I often use this command to update my Ubuntu:
sudo apt update && sudo apt upgrade -y
Here is the detailed information from the source:
It will ask for a password. You can use your account’s password. You
won’t see characters on the screen while typing, so keep on typing
your password and hit enter. This will update the packages in Ubuntu.
Now let me explain the above command.
It’s actually not a single command, it’s a combination of two
commands. The && is a way to combine two commands such that the second
command runs only when the previous command ran successfully.
The “-y” in the end automatically enters “yes” when the command “apt
upgrade” ask for your confirmation before installing updates.
Note that you can also use the two commands separately, one by one:
sudo apt update
sudo apt upgrade
It will take a little longer, because you have to wait for one command
to finish and then enter the second command.
Explanation: sudo apt update
This command updates the local database of available packages. If you
don’t run this command, the local database won’t be updated and your
system will not know if there are any new versions of packages
available.
This is why, when you run the “sudo apt update” command, you’ll see
lots of URLs in the output. The command fetches the package
information from the respective repositories (the URLs you see in the
output).

At the end of the command, it tells you how many packages can be
upgraded. You can see these packages by running the following command:
apt list --upgradable
Explanation: sudo apt upgrade
This command matches the versions of installed packages with the local
database. It collects all of them, and then it will list those
packages that have a newer version available. At this point, it will
ask if you want to upgrade the installed packages to the newer
version.
You can type “yes,” or “y,” or just press enter to confirm the
installation of updates.
So the bottom line is that “sudo apt update” checks for the
availability of new package versions, while “sudo apt upgrade”
actually installs the new versions.
upgrade
upgrade is used to install the newest versions of all packages
currently installed on the system from the sources enumerated in
/etc/apt/sources.list. Packages currently installed with new
versions available are retrieved and upgraded; under no
circumstances are currently installed packages removed, or packages
not already installed retrieved and installed. New versions of
currently installed packages that cannot be upgraded without
changing the install status of another package will be left at
their current version. An update must be performed first so that
apt-get knows that new versions of packages are available.
dist-upgrade
dist-upgrade in addition to performing the function of upgrade,
also intelligently handles changing dependencies with new versions
of packages; apt-get has a "smart" conflict resolution system, and
it will attempt to upgrade the most important packages at the
expense of less important ones if necessary. So, dist-upgrade
command may remove some packages. The /etc/apt/sources.list file
contains a list of locations from which to retrieve desired package
files. See also apt_preferences(5) for a mechanism for overriding
the general settings for individual packages.
Source: How To Update Ubuntu With Command Line And Software Updater