Computer >> Computer tutorials >  >> Programming >> BASH programming

How to Update Ubuntu Linux [Server and Desktop]

If you’re running Ubuntu Linux on your desktop, you’ll be regularly prompted to update using the built-in update tool. But what if you’re on Ubuntu Server or want to check for and run any pending updates manually?

This tutorial covers the steps required to update your Ubuntu Linux OS on Desktop and Server. But first, some relevant articles:

apt vs. apt-get Commands – What’s the Difference?

Checking Your Operating System Version in Ubuntu Linux with ‘lsb_release.’

Preamble

All package management functions should be run using the sudo command – as they require root privileges. After each command is run, you will see a list of changes that must be made that must be confirmed by typing y/n to continue.

Step 1: Updating Package Lists

To know if you need to update, you need to know if there are updates – run the following to update the lists of packages on your computer so that updates can be calculated:

sudo apt update
How to Update Ubuntu Linux [Server and Desktop]

sudo apt update

Step 2: Upgrading Packages

Now we know if there are new versions available, we can update to them with the following command:

sudo apt upgrade

apt upgrade won’t install any new dependencies or remove any old ones if an update requires them. If you want to upgrade and have your dependencies managed smartly, run:

sudo apt dist-upgrade
How to Update Ubuntu Linux [Server and Desktop]

sudo apt upgrade

My system is updated regularly, so there’s nothing to update!

Removing Packages That Are No Longer Required

If you have only run apt upgrade and some packages are no longer required, that were installed as dependencies of other packages, they will have been left behind. They can be cleaned up by running:

sudo apt autoremove
How to Update Ubuntu Linux [Server and Desktop]

sudo apt autoremove

Here’s what it looks like when apt prompts you to confirm changes