How to Add, Remove, and Update Software in Linux with Apt


Linux has several ways to install software. We can create our own executables or use AppImage to run containerized applications. But at the heart of many Linux distributions is a package management system, which for Debian-based systems like Raspberry Pi and Ubuntu is Apt.

Apt, Advanced Packaging Tool is a command-line application that manages the installation, categorization and removal of applications and their dependencies from software repositories. Apt is the heart of Debian systems and the lessons learned are applicable from the $35 Raspberry Pi to the million dollar supercomputers. Apt is available through the terminal and we can even administer systems remotely using a remote login such as SSH.

A command-line tool might seem daunting, but here we detail the most common commands you’ll use to keep your system up to date with the latest software.

So why not just use apt-get?

(Image credit: Tom’s Hardware)

Apt isn’t something new, it’s been around since 2014, but it really got noticed with Ubuntu 16.04. But many users use “apt-get” instead, so what’s the difference? They both serve the same purpose, software management, but with Apt it’s like just removing the “-get” from the command.

Take for example the commands we used in this tutorial.

apt apt get A function
proper update apt-get update Update software repositories.
proper upgrade apt-get upgrade System software upgrade.
apt install apt-get install Install an app.
apt remove apt-get remove Delete an app.
apt purge apt-get purge Delete application and user configuration files.

(Image credit: Tom’s Hardware)

But Apt has a few more commands, in fact we’ll use one in the how-to.

Order A function
proper research Search for a specific application.
apt edit-sources Edit the /etc/apt/sources.list file which contains all your software repositories. It’s actually a shortcut command that opens a text editor.
appropriate list List all installed apps.
proper show List details of an application, including all dependencies.
moo apt Uses ASCII to display a cow. Ok this is more of a joke than a tool. See also cowsay.

Apt is the tool to learn and use for everyday tasks. Apt-get is not deprecated, but it would be wise to invest your time in learning Apt.

Find software with Apt

Using Apt, we can search the software repository for specific applications and keywords.

Open a terminal and use the command apt search followed by the name of an application. In our example, we use vlc to find all apps that have vlc in the title. This command can generate a lot of results, but we can scroll up and down the list using our mouse/trackpad.

$ apt search vlc

(Image credit: Tom’s Hardware)

To pause the output of the command, we can pipe (send the output) to “minus”. The less command is used to store an output page, which we can scroll or page through using the spacebar.

$ apt search vlc | less

(Image credit: Tom’s Hardware)

To be more specific, we can pipe the output of less further and use “grep” to search for a specific keyword. Here we are looking for all VLC tools to use with Python 3.

$ apt search vlc | less | grep “python3”

(Image credit: Tom’s Hardware)

Once we have found the appropriate application, we can use the install command to install it on our system.

Installing Linux software with Apt

After identifying our required application, we then need to install it. Before running an installation, we need to perform an update, making sure we get the latest version of the software.

1. Open a terminal and use the update command. The update command will update the list of available packages for your machine.

$ sudo apt update

(Image credit: Tom’s Hardware)

2. Use the install command to download and install the selected application. In our example, we are installing VLC, a popular media player.

$ sudo apt install vlc

(Image credit: Tom’s Hardware)

After a few moments the application will be installed and available via the Terminal and via the Applications menu.

Update software with Apt

To upgrade all your installed software, we can use the “upgrade” command. By using this with “update” we can ensure that our software repositories are up to date, meaning any new software is at the latest version.

1. Open a terminal and use the update command. The update command will update the list of available packages for your machine.

$ sudo apt update

(Image credit: Tom’s Hardware)

2. Run the upgrade command to download and install the latest version of the software. We use the -y switch to automatically accept the software installation.

$ sudo apt upgrade -y

We can also chain these commands together in a one-line script. By using “&&” between commands, we can instruct the system to chain commands to run one after another. The “&&” means that the second command will only run if the first command runs successfully.

$ sudo apt update && sudo apt upgrade -y

(Image credit: Tom’s Hardware)

Depending on the amount of updates required, this can take from a few seconds to several minutes.

Removal of software

There are two ways to uninstall an application from the system. The first “removes” the application from the system, leaving all user configuration files intact. This is the most common and safest way to remove software

Open a terminal and use the following command to delete the app. In our example, we uninstalled VLC.

$ sudo apt remove vlc

(Image credit: Tom’s Hardware)

The second method is to “purge” the application and all system configuration files. This is a nuclear option, used to remove the app if we need a fresh start.

1. Open a terminal and use purge command to remove VLC and all its configuration files. Only use this command if you don’t need it or if you have saved configuration files.

$ sudo apt purge vlc

(Image credit: Tom’s Hardware)

2. To confirm that you are happy to purge the application and all configuration files.

APT package management

(Image credit: Tom’s Hardware)

Comments are closed.