In this guide, we take you through the steps on how to update Raspbian and its packages. We also show how you can do a full operating system upgrade.
Typically upgrading is a relatively simple process but always be prepared to deal with some broken packages. Also, make sure that any packages you are using now haven’t changed radically in some of the newer versions of Raspbian.
Primarily this tutorial will go through the steps of updating Raspbian packages. We will also provide a simplified explanation of how the update, upgrade, and dist-upgrade commands work.
Further down the page, we provide you with some information on how to upgrade Raspbian to a new version of the operating system.
There are numerous reasons why you might want to update Raspbian to a newer version. One of the biggest reasons is the ease of access to newer versions of packages. You will also gain access to modern packages that were deemed too unstable for your current release.
For example, PHP 7 is not available in Raspbian Jessie and Wheezy but is readily available in Raspbian Stretch as it was still in its infancy when Raspbian Jessie was pushed out.
How to Update Packages on Raspbian
Luckily for us, updating packages on Raspbian is incredibly easy. It involves typing two very simple commands into the terminal.
It is good to remember the two commands that are shown below as they will quickly become some of your most used Linux commands.
sudo apt-get update sudo apt-get upgrade
The first of these commands (sudo apt-get update) makes a call to the Advanced Packaging Tool (apt) to update the package list.
This first command is highly important as the install and upgrade commands only search the local package list and won’t make any attempts to update themselves.
The update command works by searching the /etc/apt/sources.list file. It then polls all the websites in the list for available packages and then creates a list of their download location and their current version.
The default location that Raspbian uses for its packages can be found on Raspbian’s mirror director, and this mirror director is designed to direct you to the closest download provider.
Failing to run the update command before running install or upgrade can also cause you to run into download errors, especially when packages are moved around on the mirror server.
The second command (sudo apt-get upgrade) utilizes the Advanced Packaging Tool (apt), but this time it uses it to check all currently installed packages against the package list.
If there is a version mismatch for any of the packages it will attempt to update it by downloading the new version from the link in the list. The upgrade tool will never remove a package.
Sometimes packages will be held back during an upgrade due to a change in the package’s dependencies. To update the packages that are held back, we must use a different command.
sudo apt-get dist-upgrade
The sudo apt-get dist-upgradecommand utilizes the Advanced Packaging Tool (apt). It starts by performing an upgrade as usual, but when it comes to a package that has changed dependencies it intelligently handles them. This logic means it could also potentially remove packages in favor of others.
How to Update to the Latest Version of Raspbian
There have been quite a few major updates to the Raspbian operating system. To help make your life easier, we have listed all the latest version jumps below.
- Update Raspbian Wheezy to Raspbian Jessie
- Update Raspbian Jessie to Raspbian Stretch
- Update Raspbian Stretch to Raspbian Buster
I hope that you now know how to update Raspbian packages and the guides above will help you upgrade to the latest version of the Raspbian operating system.
You can now continue with working on some Raspberry Pi projects or just using your Pi as you would normally. If you run into any issues or have any feedback, then feel free to drop a comment below.