How to Easily Update Raspbian

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.

How to update Raspbian

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-upgrade command 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.

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.

9 Comments

  1. Malcolm Welch Sr on

    When will we be able to upgrade from Stretch to Buster? Any idea?

    Thanks!

  2. Cameron on

    I am upgrading from raspbian Jessie to stretch , and I was wondering if this would erase my stuff (code, programs, etc.) Thanks!

    1. Gus on

      Hi Cameron,

      It has been awhile since I have had to upgrade from jessie to stretch myself, however it should not from memory touch any of your personal stuff.

      However it will cause every package to update to the latest available versions in the Stretch repository so that may or may not break stuff, purely depends what you are running.

      Cheers,
      Emmet

  3. Tim Connor on

    I love that case, where did it come from?

    1. Gus on

      Hey Tim,

      That case is the Pibow Timber, which is sadly no longer manufactured.

      Cheers

  4. Lutz on

    cat /etc/os-release

    will let you know which version you are running.

    1. Hughman on

      Thank you! Success! Linux 9 (stretch)

  5. HughMan on

    Thanks for the awesome project! You do a great job for the community. I enjoy every one of your projects! For this one, is there a way to check and make sure I did everything correctly? For example, a place to look and verify I am in fact running stretch?

Leave a Reply

Your email address will not be published. Required fields are marked *