Introduction
Regularly running a Raspberry Pi update ensures optimum performance and security of the device. Bugs in code allow hackers to exploit your Raspberry Pi. These known vulnerabilities pose a significant threat, especially if a device is connected to the internet, or if you access it remotely.
Raspbian Buster is the latest version of this OS. Since its release in September, there have been several smaller updates. A Raspberry Pi update can include improvements to the bundled software, security patches, and other performance-related enhancements.
Follow this tutorial to learn how to update your Raspberry Pi.
Prerequisites
- A Raspberry Pi with Raspbian OS
- An up to date backup of your files before starting the update
- A user account with sudo
- Active internet connection
Update Raspberry Pi
Since Raspbian is based on Debian, you can update Raspberry Pi with the apt tool in a terminal window.
1. Start by updating the repository package list:
sudo apt update
Note: If you are using the default user account pi, the password is raspberry. We advise you to change the password to avoid potential breaches.
2. Before starting the upgrade, you can check the available space on your device. Run the following command:
df -h
3. The upgrade tool tells you how much space it needs to complete the process. To upgrade all packages on your Raspberry Pi, enter this command:
sudo apt full-upgrade
Note: The apt full-upgrade
and apt-get distro-update
command perform the same function. apt full-upgrade
does not update to a new major release of Raspbian. This command keeps your current release up-to-date.
4. Let the upgrade finish. Once done, you will get a pop-up confirmation message:
5. If you want to free up some space on your Raspberry Pi, run the clean
command to remove the downloaded .deb packages:
sudo apt clean
6. To reboot your device, enter:
sudo reboot
Update Raspbian from an Older Version to Buster
To update Raspbian from an older version (for example, Stretch) to the latest (Buster, at the time of writing), you need to edit a few files.
1. Locate the sources.list file in the /etc/apt/ directory and replace every instance of the word stretch with the word buster. Use the editor of your choice. We will use vi:
sudo vi /etc/apt/sources.list
2. Save the changes and exit the editor.
3. Do the same for the raspi.list file:
sudo vi /etc/apt/sources.list.d/raspi.list
4. When you finish, update your package list:
sudo apt update
5. Then, run this command to complete the upgrade:
sudo apt dist-upgrade
6. The upgrade takes some time. Confirm with yes when prompted. Use the space bar to scroll if the installation shows a page of information and press q to resume the upgrade.
7. Reboot the device when the upgrade completes:
sudo reboot
Confirm Raspberry Pi Update
You can quickly check from the terminal if your Raspbian successfully updated to Buster.
Run the terminal from the application bar and enter:
cat /etc/os-release
Conclusion
By following this tutorial, you learned how to keep your Raspberry Pi updated. This guide also showed you how to upgrade from Raspbian Stretch to Raspbian Buster.
Make sure to update Raspberry Pi frequently to avoid security and performance issues.
If you are looking for other useful Raspberry tutorials, be sure to visit the Java Installation On Raspberry Pi and Ubuntu Mate Installation on Raspberry Pi 2 or 3 guides.