How to Update and Upgrade Raspberry Pi OS or Its Packages

Jinku Hu Feb 02, 2024
  1. Package Management Basics on Raspberry Pi OS
  2. Upgrade Software Packages on Raspberry Pi OS
  3. Remove Software Packages on Raspberry Pi OS
  4. List Information About Software Packages on Raspberry Pi OS
How to Update and Upgrade Raspberry Pi OS or Its Packages

This article will introduce several methods to update and upgrade Raspberry Pi OS or its packages.

Package Management Basics on Raspberry Pi OS

Generally, most Linux distributions offer the feature of package management, which provides ease of use for the end-users to configure and maintain the up-to-date system. Raspberry Pi OS is a Debian-based Linux distribution, so it comes with the APT (Advanced Packaging Tool) command-line interface for package management.

You also might be familiar with the APT interface if you had some experience with Ubuntu-based systems. The APT interface is mostly exposed using the apt command, which we will utilize in the following examples.

Usually, you should aim to update the system and packages to the latest version because of the security patches, but sometimes you might need to manually install the newest packages to satisfy the dependencies of some other software package. You can install a new package (e.g., htop) using the following apt command:

sudo apt install htop

Notice that most apt commands require root privileges, so each command should be using sudo prefix to temporarily elevate the current user’s permissions and modify packages on the system. Alternatively, you may also specify multiple package names as a space-separated list for bulk installation, which is demonstrated in the next command:

sudo apt install htop cmake valgrind python3-venv

Upgrade Software Packages on Raspberry Pi OS

You can upgrade existing software packages using the apt upgrade command. The upgrade option will install available upgrades to all packages currently installed on the Raspberry Pi. Meanwhile, apt update command is used to retrieve package information from the sources.

sudo apt update && sudo apt upgrade

The above command may also install dependency packages as required, and it usually reports the corresponding names before user confirmation. Note that this command will not remove conflicting package dependencies when needed. The latter feature is separately provided by full-upgrade option that might offer a more headless solution for you to upgrade packages on the system.

sudo apt full-upgrade

Remove Software Packages on Raspberry Pi OS

Installed packages can be uninstalled by adding the remove option to the apt command and specifying the names of packages:

sudo apt remove htop cmake valgrind python3-venv

Mind that the remove option leaves behind some configuration files that are usually reused if the removed packages are installed in the future. In case you need to delete the mentioned leftover configuration files, you must specify the purge option to the apt command as shown in the following example:

sudo apt purge htop cmake valgrind python3-venv

List Information About Software Packages on Raspberry Pi OS

Sometimes, you might need to check if the given package is available on the repositories and to list their dependencies. These features are included in the apt show command, and it can be run without the sudo prefix as it does not require elevated privileges.

apt show python3-venv
Author: Jinku Hu
Jinku Hu avatar Jinku Hu avatar

Founder of DelftStack.com. Jinku has worked in the robotics and automotive industries for over 8 years. He sharpened his coding skills when he needed to do the automatic testing, data collection from remote servers and report creation from the endurance test. He is from an electrical/electronics engineering background but has expanded his interest to embedded electronics, embedded programming and front-/back-end programming.

LinkedIn Facebook

Related Article - Raspberry Pi