The apt Command – A Practical Usage Guide

Filed Under: UNIX/Linux
Apt Command Tutorial

This guide will walk you through everything you’d need to start using the apt command in Linux. Packages help in delivering or installing any application on a Linux running system. A Linux package is the pre-compiled version of any application.

Packages make it easier for the end-user to work with applications. Instead of compiling from source, a package is like a Windows executable file that you can double-click to install.

These packages are available on the distribution’s repositories. You sure can manually handle the packages on your system if you like. But a package manager automates those tasks for you. Let’s get more understanding of the apt package manager today.

What’s the apt command anyway?

The Advanced Package Tool, Or ‘APT’ for short, is the package management service for Ubuntu and Debian based systems. If you have been using Linux for a while, you must have seen the apt command before.

APT provides a user-friendly and interactive front-end tool for the users to manage packages without the complexity of the dpkg command.

The apt command is responsible for installing, updating, removing, and managing packages of Ubuntu and Debian based systems.

This package manager soared in popularity after its introduction within the Ubuntu 16.04 LTS version. While the apt command in Linux offers a wide range of functionality, this tutorial will briefly discuss the most essential ones – installing and removing packages, updating and upgrading repositories, and finally searching for packages.

Exploring the apt command

This command takes away the complexity of the dpkg interface and provides users with a simple and easy to understand method for managing packages in their repositories.

Let us explore the common functions of the apt command. As the command works the same for both Debian and Ubuntu systems, we will only mention Ubuntu in this tutorial from now on.

1. Installing a package

The most basic use of the apt command in Ubuntu is for package installation. While many general-purpose programs and services come pre-installed with the operating system, it doesn’t take away the need to install new software on your system.

The apt command in Ubuntu allows us to install packages using the install option. Here is the syntax for installing a program or service using the apt command on Ubuntu.

sudo apt install [package name1] [package-name2] [package-name3]

Here is how we use the apt install command to install a package on Ubuntu. In the screenshot below, we install the vsftpd package for an FTP server on Ubuntu.

Sudo Apt Install
Sudo Apt Install

This command also allows the user to install multiple packages at once by listing the package names one after another separated by spaces as shown in the syntax example.

2. Uninstalling a package

When you no longer need a program or service on your system, there is no use keeping it. It will only occupy system resources that you can devote to other purposes.

The apt command takes care of it! We can uninstall a program or service from our system using the apt remove option.

Here is the syntax for removing a program or service from our system using the apt command.

sudo apt remove [package name]
Sudo Apt Remove 1
Sudo Apt Remove

However, There will be some orphaned files from the installed package even after it’s removed. In such a case you can use the purge remove option.

sudo apt --purge remove [package-name]

This is generally a cleaner way of removing a package which also removes the files along with the package here automatically.

3. Auto remove orphaned packages

Apt command handles dependencies for you so the don’t generally need to worry about them when installing a package.

But the case is different when you’re uninstalling packages. Only the critical dependencies are removed while removing a package. The rest stay in our systems.

That’s where the autoremove functionality comes into play.

sudo apt autoremove

The above command will uninstall all the orphaned packages from your system. This includes any package that was installed as a dependency and is no longer necessary.

4. Updating APT repositories

The dpkg stores all the packages available for installation on your Linux distribution. However, as these packages are stored locally you can often end up having old versions of packages for a program when newer versions have been released.

This causes a need for a method to update your repositories. Guess what? The apt update option has got you covered.

sudo apt update

It checks the online repositories and downloads all the updated packages to your local repository.

5. Upgrading your system packages

Once we update our local repositories, it is a wise choice to upgrade all your programs and services to the latest versions. This is possible through the apt upgrade option of the apt command on Ubuntu.

sudo apt upgrade

This will scan all the installed packages on your system and find the programs or services which are running on an older version. Next, it will upgrade all such programs and services to the latest available versions.

This is an essential command as it allows you to initiate a system-wide upgrade using a single command.

But the above command will only upgrade non-critical packages. If there’s a kernel update available, we’ll need to perform a full system upgrade using the following command:

sudo apt full-upgrade

The above command will upgrade the Linux kernel along with any system critical packages that weren’t upgraded with the previous command. You will generally need a restart after a full-upgrade so the new kernel boots up.

6. Searching for a package

The apt search command is the most common command used to search for packages on Ubuntu. It is designed to search the package name along with its metadata such as the description, dependencies, source and version.

The command returns all the packages whose name or metadata matches the specified search keyword. Following is the syntax for searching a package using the apt search command.

sudo apt search [keyword]


Linux based systems utilize packages for installing and running all kinds of applications and services. This makes it essential for a Linux user to be able to manage and keep a note of all the available packages in their local repository.

The dpkg is difficult to navigate even for experienced Linux users. Hence the Advanced Package Tool is cherished as a valuable tool to help people interact with the packages in their repositories.

This tutorial aimed at getting you up and running with the command. If you have any feedback, feel free to reach out to us in the comments below.

Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors