The apt-get command to install packages

The apt-get command is used to install software on the Raspberry Pi. apt-get is also used to update and remove the Raspbian software, which are also known as packages. This will also work if your are using any Debian-based operating system.

First, check that all packages are up to date:

sudo apt-get update
sudo apt-get upgrade

This can be run together as one entry:

sudo apt-get update; sudo apt-get upgrade

To install a package

sudo apt-get install [packagename]

To Un-install a package

sudo apt-get remove [packagename]

Search for Packages

(Do sudo apt-get update before you search)

sudo apt-cache search [packagename]

Check which Packages are installed

dpkg -l
dpkg --get-selections

To find out if a package is already installed

dpkg --get-selections | grep [packagename]

Clean up

It’s a good idea to do an occasional cleanup to make sure no unwanted files are left behind.

sudo apt-get autoclean