If you manage a Linux server, you'll eventually need to remove software you no longer use. Maybe you installed something to test it out, or a package is taking up disk space, or you're cleaning up before handing off a server. Whatever the reason, apt remove is the command you'll use to do it.

APT (short for advanced package tool) is the tool Ubuntu uses to install, update, and remove software packages. If you've ever run apt install to add something to your server, apt remove is its counterpart for taking that software back off.

In this guide, we'll walk through exactly how to uninstall apt packages with apt remove, what happens when you do, and how it differs from a similar command called apt purge. By the end, you'll know which one to use and when.

A quick note before we start: removing the wrong package, especially a system package your server depends on, can cause problems. We'll cover how to check what a package does before removing it, so you don't run into surprises.

TLDR: This guide walks you through safely uninstalling Ubuntu packages using APT. It starts with the basics of checking what's installed before removing anything, then covers the actual removal commands and how they differ, plus a section on managing unofficial package sources.

  • Beginner-friendly guide on uninstalling Ubuntu packages with APT
  • Covers checking what's installed first (apt list, apt search, apt show)
  • Explains apt remove (deletes package files, keeps config) vs apt purge (deletes both)
  • Covers apt autoremove for cleaning up leftover dependencies
  • Includes a section on managing PPAs (unofficial package sources)
  • Closes with guidance on when to use remove vs. purge

What you need before you start

To follow along, you'll need access to your server through a terminal or SSH client, or through VPSServer.com's browser-based console.

APT comes pre-installed on Ubuntu servers, so there's nothing extra to set up. The commands in this guide assume you're logged in as root. If you're logged in as a regular user instead, you'll need to add sudo before each command (for example, sudo apt remove instead of apt remove).

To see the full list of things APT can do, type:

aptadd

How to Uninstall a Package with Apt Remove

This shows all the available commands and options, useful if you want to explore beyond what's covered in this guide.

Before making any other changes, it's a good idea to update your packages to their latest versions:

apt upgrade

How to Uninstall a Package with Apt Remove

To see which packages have updates available before you commit to upgrading them, use:

apt list --upgradable

How to Uninstall a Package with Apt Remove

Checking what's installed before you remove anything

Before removing a package, it helps to see what's currently installed and confirm you have the exact package name.

To see every package installed on your server, type:

apt list

How to Uninstall a Package with Apt Remove

This can return a long list, especially on a server that's been running for a while.

To narrow things down, you can search for a specific package by name, or part of a name:

apt search

For example, to find installed VLC video plugins, you'd run:

apt search vlc-plugin-video

This returns every package that matches the search string.

How to Uninstall a Package with Apt Remove

Once you've found the package you're looking for, it's worth checking what it actually does before removing it. You can view its details with:

apt show

This displays the package's manifest, including a description, so you can confirm it's what you think it is and understand what removing it might affect.

How to Uninstall a Package with Apt Remove

Managing Ubuntu packages 

Ubuntu keeps an official, secure repository of installed packages, and this is where APT downloads software from by default. Because these installed packages go through Ubuntu's official channels, they're generally safe to install and easy to manage with the commands we've already covered.

This section focuses on removing packages that came from that official repository. Ubuntu also lets you install software from other sources, but that's a separate topic outside what we're covering here.

Installing a package

Before we get into uninstalling, it helps to understand what happens when a package is installed in the first place, since that explains why removing it works the way it does.

When you install a package with APT, it installs that package's files to their designated locations across the system, and creates configuration files separately in places like /etc. These configuration files store settings for that package, separate from the package's core files.

To install a package, use:

apt install

For example, to install Docker, type:

apt install docker.io

How to Uninstall a Package with Apt Remove

This matters for removal because, as we'll cover next, apt remove only deletes the package's core files, not these separate configuration files. That's intentional: it makes reinstalling a package later much simpler, since your previous settings are preserved.

Uninstalling packages

You remove a package with the apt remove command and the package name:

apt remove

For example, to remove docker:

apt remove docker.io

After you press Enter, apt asks you to confirm that you want to remove the package. 

How to Uninstall a Package with Apt Remove

Type Y, and apt removes the package.

How to Uninstall a Package with Apt Remove

Purging packages

Often, you'll want to remove a package and all of its configuration files at once, rather than leaving them behind. To do this, use the apt purge command with the package name:

apt purge

For example, to purge docker:

apt purge docker.io

How to Uninstall a Package with Apt Remove

As with apt remove, APT asks you to confirm before proceeding:

Do you want to continue? [Y/n]

Type Y, and APT removes the package along with its configuration files.

How to Uninstall a Package with Apt Remove

Use apt purge when you're sure you won't need that package's old settings again, for example, if you're decommissioning a server or cleaning up software you installed by mistake. If there's a chance you'll reinstall the package later and want to keep your configuration, apt remove is the safer choice.

Removing unused packages

When you install a package, it often brings along other packages it depends on. If you later remove that package, those dependency packages can be left behind, even though nothing on your server needs them anymore.

Rather than tracking these down one by one, APT can find and remove them all at once with:

apt autoremove

How to Uninstall a Package with Apt Remove

APT will show you how much disk space this will free up, and ask you to confirm before proceeding:

Do you want to continue? [Y/n]

Type Y, and APT removes the unused packages.

How to Uninstall a Package with Apt Remove

It's a good habit to run apt autoremove after removing or purging a package, since it cleans up anything that was only installed to support the package you just removed.

Managing unofficial packages (PPAs)

For most situations, it's best to stick with Ubuntu's official packages, since they're tested and maintained through Ubuntu's own channels. But sometimes you might need software that isn't available there yet, for example, a newer version of a program with a fix you need, or a package your team is testing internally.

For these cases, Ubuntu supports Personal Package Archives (PPAs), which let you install software from outside the official repository.

Connecting to and downloading from a PPA repository

You connect to a PPA repo with:

add-apt-repository /

For example, to add a PPA for the latest graphics drivers:

add-apt-repository ppa:graphics-drivers/ppa

How to Uninstall a Package with Apt Remove

APT will ask you to confirm the connection by pressing enter. It will install the packages from that PPA.

How to Uninstall a Package with Apt Remove

The PPA is installed.

How to Uninstall a Package with Apt Remove

Removing PPA connections and packages

If you want to remove a PPA and stop using its packages, use:

add-apt-repository --remove ppa:user/ppa-name

For example, to remove the graphics drivers PPA from the example above:

add-apt-repository --remove ppa:graphics-drivers/ppa

How to Uninstall a Package with Apt Remove

APT will ask you to confirm the request. Press enter, and it removes the packages associated with that PPA.

How to Uninstall a Package with Apt Remove

Conclusion

Use apt remove when you want to uninstall a package but might reinstall it later and want to keep its settings. Use apt purge when you're ready to remove a package and its configuration files for good. And run apt autoremove afterward to clean up any leftover dependencies that are no longer needed.

Effectively managing your Ubuntu packages is essential for maintaining the security, stability, and performance of your VPS. Ubuntu’s APT command provides all you need to manage packages on your cloud-hosted server, including regular updates and informed package removal. With these commands, you can keep your Ubuntu server clean, secure, and free of software you no longer need.

Bilal Mohammed
The author
Bilal Mohammed

Bilal Mohammed is a SOC analyst and cybersecurity expert who is passionate about making the internet safer. He has expertise in penetration testing, networking, network security, web development, and security operations center (SOC) services. In his spare time, he looks for security and design vulnerabilities to protect against attacks from hackers.