How to Upgrade Ubuntu using the Command Line

on

update vs upgrade vs dist-upgrade vs do-release-upgrade

1. sudo apt-get update

Updating your sources list will not install any program updates, but will retrieve the list of latest updates. Run this command before one of the following upgrade commands to ensure you are upgrading to the latest versions.

2. sudo apt-get upgrade

This command will upgrade all installed packages. Run the update command first, before this one, to ensure you are updating to the latest packages. It does not remove currently installed packages and it will not retrieve packages that are not already installed.

While this command appears to be a safer one than the `dist-upgrade` command since it doesn't remove whats there nor add something that wasn't there before, however for programs to work properly they may depend on addition and removal of other programs. Top answers on AskUbuntu have recommended to do them both.

3. sudo apt-get dist-upgrade

dist-upgrade performs a "smart upgrade" that intelligently handles changing package dependencies to have new versions, and it may remove packages.

While automatic package removals/additions might sound scary, it might be necessary to ensure proper functionality and correct dependency resolution.

Top answers on AskUbuntu recommend performing in this order [source 1], [source 2]

sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade
Or as a one-liner (&& operator only moves onto next command upon the former succeeding):
sudo apt-get update && sudo apt-get upgrade && sudo apt-get dist-upgrade

?! sudo do-release upgrade

Be careful! This command will upgrade your operating system to a later version, which can have all kinds of adverse effects not only to your data but to your currently installed programs.

Do your research first before making the decision to upgrade your operating system. Backup your files and find a way to restore your system image if things go bad. This is not a command you want to use on a regular basis, use the other commands as described in the previous section for regular security and program updates. This command should only be used when you specifically know you want the newest operating system version.

Also See

Upgrading your computer is very important, be sure you understand what is happening when you run these commands. Here are some offical references where you can learn more: