The Raspberry PI’s Raspian Distribution, like many Linux Distributions, leverages the Advanced Packaging Tool, otherwise known as APT to manage software upgrades. You can simply run the apt-get update and apt-get dist-upgrade commands to update your PI.
The first step is to update the local package index. This can simply be though of as the list of available packages from the online repository. The update command downloads the package lists from the repositories and updates the local package lists with the newest package information and their respective dependencies.
sudo apt-get update
The update command alone does not update any software, it simply updates the list of available software or packages. The “dist-upgrade” command installs the newest versions of all packages currently installed on the system from the sources in the source list. Additionally, “dist-upgrade” intelligently manages package dependencies by upgrading packages or installing new packages as required.
sudo apt-get dist-upgrade
On occasion it may be necessary to clean up package files to free up space. apt-get download packages and stores them in a local archive. The apt-get clean command will clear out the local repository of retrieved package files.
sudo apt-get clean