Not always clear how to properly update its version of Linux, I’m personally under Ubuntu, they are the same commands as many other versions of Ubuntu, I’ll show you in this tutorial how to update it well and also what common mistakes you might encounter.

Always execute commands in admin / super user mode via sudo su.

Step 1: Command to execute the update

To properly update you have two types of commands, update and upgrade. 

sudo su
apt -y update && apt -y upgrade

Step 2: Cleaning the space used by the update

Updating your version of Ubuntu will download files, you will need to clean them after your update through this command.

apt -y autoremove && apt -y autoclean

Errors you might encounter with an apt update or apt upgrade

Reading package lists… Error!

Here is typically the kind of error you may have:
SystemError: E:Read error - read (5: Input/output error), E:The package lists or status file could not be parsed or opened.

This means that your package lists are not read correctly. Maybe a problem with an installation, or a corrupted disk? Let’s try to delete this package list and recreate it.

sudo rm -r /var/lib/apt/lists/
sudo mkdir -p /var/lib/apt/lists/partial

apt -y update && apt -y upgrade
apt -y autoremove && apt -y autoclean

Dpkg returned an error code (1) ?

What is this error? Most often this will return this error: E: Sub-process /usr/bin/dpkg returned an error code (1)

Several solutions are available to you. We will see 3 in this article.

Solution 1: Finish installations that have not finished properly.

sudo apt-get install -f

Solution 2: Delete a possible package posing the problem.

sudo apt remove

Solution 3: Reconfigure dpkg.

sudo dpkg –configure -a