How to Update Packages in Ubuntu via Command Line
This quick tutorial will show you how to update packages in Ubuntu via the command line. There are only a few commands needed to finish the job.
Create A Backup
Before making any updates on your server, especially when processing updates for vital packages, it's always a good idea to first create a backup or snapshot of your server. Should anything go wrong during the upgrade process that you can't easily roll back, you'll have a backup that you can use to restore.
Check Your Access
You'll also need to make sure you have administrative access to the server. If you don't, you won't be able to run these updates yourself and will need to contact someone who has access.
Update Packages in Ubuntu
When updating packages in Ubuntu, you're instructing the server to fetch all pending package lists from the available repositories and update the index files on your machine:
$ sudo apt update
Upgrade Packages in Ubuntu
Now that the index files are updated, you'll need to upgrade the packages and their dependencies. This command upgrades the existing packages to their latest versions. It does not remove the obsolete package versions:
$ sudo apt upgrade
Update & Remove Obsolete Packages
If you're looking to upgrade your packages and their dependencies to their latest versions and remove any existing obsolete packages in one shot, this command will do the trick:
$ sudo apt dist-upgrade
Process Security Updates
If you're only looking to install the latest security updates on your Ubuntu server, you can do so while bypassing all other non-security packages with this command:
$ sudo apt install unattended-upgrades
This command will run through the upgrade process silently, installing updates without user consent or interaction.
If you'd rather run the interactive process that steps through each of the updates individually, just add the
-d switch to the end of the command:
$ sudo apt install unattended-upgrades -d
Reboot Your Server
Once all of your packages and security updates have been updated and installed in Ubuntu, make sure to reboot your server for all updates to take effect.
Once the reboot has been completed, do a once-over through your running applications to ensure everything is updated correctly without error.
As a rule of thumb, it's a good idea to retain your backups for at least a few months to ensure you still have access to certain restore points if needed.
In this tutorial, you learned how to update packages in Ubuntu and install security updates independently from all other updates.
Created: June 02, 2022
Run 'do-release-upgrade' to upgrade to it.
2 updates could not be installed automatically. For more details,
-- my issue is how to install new version. it is asking me to install 1st 2 updates which is not done then go ahead but i do not know how to perform that to install 2 updates which is not done.. any help ?