In this post, we will see how to update the version of Raspbian installed on our Raspberry Pi when a new version of the operating system is available.
For this, we will use the APT tool, as we saw in the previous post about How to Install and Update Programs with APT.
In fact, the process to update the Raspbian version is very similar to a normal package update. The only difference is that, to update Raspbian, we will use the following instruction:
sudo apt-get -y dist-upgrade
This command performs the same actions as upgrade, that is, it updates the installed packages to the latest version. But, additionally, dist-upgrade is also capable of adding uninstalled packages or removing obsolete ones.
So, essentially, after updating the Raspbian version with dist-upgrade, we will have the system practically the same as if we downloaded and installed the new version of Raspbian from scratch, but keeping our data.
The only difference is the additional packages (extra programs, etc...) that have been included in the new version of Raspbian, which obviously will not be updated because we never had them installed.
If we are interested in these packages, we will have to install them manually. Fortunately, in general, we won’t be interested in these packages
Update Raspbian
Let’s see the complete process to update Raspbian. First, we check the current version with the following command:
uname -a
Next, we execute the following commands to update the Raspbian version:
sudo apt-get -y update sudo apt-get -y dist-upgrade sudo apt-get -y autoremove sudo apt-get autoclean sudo reboot
With this, we are updating all the system packages, then we clean the local package repository and, finally, we reboot the Raspberry Pi.
The complete update process can be long, even taking an hour or more. For this reason, we have used the -y parameter, which prevents the commands from asking if we want to continue, and the process stops because it’s waiting for us to say yes.
Once the update process is finished and the Raspberry Pi has rebooted, we check the installed Raspbian version again with:
uname -a
Verifying that, indeed, the Raspbian version has been updated correctly.
Install Experimental Kernel
Additionally, it is possible to update the installed Raspbian version to the latest available version (including unstable ones) of Raspbian with the following command:
rpi-update
Although at first glance it may seem that this is the “normal” command, it is very important to emphasize that this command installs the latest available version of Raspbian, including unstable test versions. Therefore, in general, it is not recommended to use this command to update Raspbian or we could turn our Raspberry Pi into a brick, forcing us to reinstall everything from scratch.
Recover Original Firmware
If at any time you have tried to update Raspbian and have had the misfortune of encountering an error, as long as we can start a command console, we can recover the original firmware with the following command:
sudo apt-get install —reinstall raspberrypi-bootloader raspberrypi-kernel
If this doesn’t work, well, you know, brick. We will have to reinstall the operating system from scratch and start over from the beginning.

