Introduction

In Linux, special tools were developed for managing applications. Application software for Linux typically comes in a package. The default package manager for Ubuntu and Debian is apt-get.

Linux operating systems use a software tool known as a package manager to make sure the software is correctly installed and up-to-date. It also keeps a current list of available software, stored externally in a database called a repository

This guide shows you how to use apt-get commands to manage packages in Ubuntu and Debian.

Prerequisites

  • A Linux operating system
  • An internet connection
  • Access to a terminal / command line

Tools/Software

  • The apt-get tool, pre-loaded in Ubuntu and Debian-based Linux

Installing Apt-Get

The apt-get tool is included by default in most Debian-based versions of Linux, including Ubuntu.

Different versions of Linux, like CentOS, Fedora, or FreeBSD, use different package managers. The theory is similar, but the actual commands will be slightly different. Refer to the manual pages to use package managers in other flavors of Linux.

Step 1: Open a Terminal or Command Line

Open a terminal  or command line (also known as a Console window, or a Shell)

Right-click the desktop, then left-click Open Terminal.

Or you can click the system menu > Applications > System Tools > Terminal.

Alternatively, you can use use the Ctrl + Alt + A function keys to open Terminal.

Step 2: Updating Your Database of Available Packages

Linux software is maintained in databases that you can access over the internet. Your machine keeps a sort of a “master list” of available software.

Refreshing your local list of software before installing a new application is a good habit to develop.

To refresh your local list of software.

Type the following in a terminal:

sudo apt-get update

Your system will check the repositories for updated information.

NOTE

The sudo command tells Linux to perform the operation as a temporary administrator.  It may ask you for your password.

Step 3: Installing a Package, and Adding New Repositories

Most Linux software developers give instructions on how to access their software repositories. One way to add repositories is to install a software package called software-properties-common. This enables the add-apt-repository command (used in the next step).

This will walk you through how to install a package using apt-get.

In your terminal window, type:

sudo apt-get install software-properties-common

Your system will reach out to the repositories, then download and install the software.

Once that completes, enter the following:

sudo add-apt-repository ppa:[repository_string]

Replace [repository_string] with the name of the repository you’re adding. This is usually located on the software developer’s website.

Once that completes, run another update (see Step 2).

Step 4: Install Software Updates To Packages

One handy feature of apt-get is that it can check for and apply software updates to all your packages at once. Usually, this is handled automatically on a schedule.

But if you’d like to manually scan and install updates, including updates for your core operating system, run the following command:

sudo apt-get upgrade

Your system will contact the servers, and start downloading all available software updates. This may take some time. Allow the process to complete.

Step 5: Uninstalling With Apt-Get

The process for uninstalling an application using apt-get is simple.

Enter the following:

sudo apt-get remove [package_name]

Replace [package_name] with the system name of your application.  This may be different from the popular name, so make sure you double-check the name if you receive any errors.

Conclusion

Now you know how to manage packages on Ubuntu and Debian with Apt-Get.

Package managers are an incredibly handy feature for Linux users. They handle most of the grunt work, checking for updates and dependencies for you. With a basic understanding of apt-get, you gain a lot of control over your Linux installation.