• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
NameHero® Blog

NameHero® Blog

Web Hosting Tips & Resources From NameHero

  • AI Agents
    • OpenClaw
    • Claude Code
    • n8n
    • Hermes Agent
    • Open WebUI
    • Docker
  • Hosting
    • Web Hosting
    • WordPress Hosting
    • WooCommerce Hosting
    • Enterprise Hosting
    • Email Hosting
    • HeroicGuard
    • GPU Hosting
    • Website Builder
  • VPS
    • Managed VPS
    • Unmanaged VPS
    • Flex VPS
  • Reseller
  • Gaming
  • Domains
  • Account
  • Blog Home
  • Categories
  • Authors

How To Uninstall A Package In Ubuntu

Bhagwad Park

Published on: June 28, 2023

Categories: Linux Command Line, VPS Hosting 0

Ubuntu is a great choice for your VPS OS. While I personally prefer to use CentOS due to familiarity, Ubuntu wins for its fast release cycle, user-friendliness, and willingness to adapt to new technologies faster than RHEL-based systems. One example that we’ll touch upon in this tutorial is Snap packages, which come bundled with all their dependencies, don’t require any additional repositories, and also run sandboxed.

One of the first things you need to learn when starting with Ubuntu is how to install and uninstall packages. If you’re not used to the command line, it can be a bit of a learning curve, but it’s really not hard. Most of the time, if you’re installing standardized packages, it just requires a line or two, and before you know it, you’ll be installing and uninstalling packages like a pro! One thing to remember is package management hygiene, which I’ll also discuss below.

So let’s get started.

Table of Contents
  • Ubuntu Package Management
    • Ubuntu Package Managers – APT, DPKG, and SNAP.
  • Example Package in Ubuntu
  • What You Need to Use APT for Uninstalling a Package
    • Finding the Exact Name of the Package to Uninstall
  • How to Uninstall an Ubuntu Package Using APT
    • Purging Packages from Ubuntu Instead of Uninstalling
  • Removing Snap Packages on Ubuntu
    • Purging Package with Snap on Ubuntu
  • Conclusion

Ubuntu Package Management

A package is a like an executable “.exe” file or “.msi” file in Windows. But it’s not a binary – it’s actually just a compressed file that contains all the binaries your system needs to run the program. It also contains metadata that tells Linux where to install the files. Snap packages also contain the package’s dependencies – files required for it to run.

For Ubuntu specifically, packages come with the “.deb” extension. DEB stands for Debian – the Linux distribution, whose architecture Ubuntu uses as its base.

Ubuntu Package Managers – APT, DPKG, and SNAP.

Just like in Windows, the Linux system keeps track of which packages are installed, along with how to remove them. Without this, you’d quickly lose track of what you installed and clutter up the system, leading to instability and a bloated OS. To manage packages in Ubuntu, you can use either APT or DPKG.

APT is usually better, since it’s more high-level, downloads the packages, and installs the dependencies for you. DPKG is actually the package on which APT relies, so it’s more low-level. DPKG doesn’t download packages or resolve dependencies. That’s why, for this tutorial, I’m only talking about installing and uninstalling packages in Ubuntu using APT.

Snap packages are different, in that they’re sandboxed from the rest of the operating system packages, and Ubuntu also updates them automatically in the background.

Example Package in Ubuntu

One neat application to monitor Ubuntu is called “btop”. Here’s a screenshot showing the display of system resources:

Btop Screenshot on Ubuntu
Btop Screenshot on Ubuntu

Below, I’m going to use this for my examples.

What You Need to Use APT for Uninstalling a Package

To manage packages in Ubuntu, you need to have administrative rights. This means either logging in as the root user (not recommended) or gaining administrative access by being a “sudo” user. Not all users can gain administrative access. Here’s a tutorial on how to allow a Linux user to run sudo commands. The above tutorial is on a CentOS distribution, but it should still work on Ubuntu.

The second thing you need is the exact name of the package. Since we’re using the command line, there’s no point-and-click.

Finding the Exact Name of the Package to Uninstall

Let’s say I want to confirm that the name of the package is “btop”. I use the following command:

apt-cache search btop

Which gives me this output:

Search for the Exact Package Name
Search for the Exact Package Name

So I know that I have the right name.

If you don’t remember the package name at all, you can list all the packages installed, sorted alphabetically by using the following command:

dpkg --get-selections

From the above list, you can scroll down till you find the package you want. Perhaps you remember what it starts like, and you can find the package name here. If you want, you can filter the above list to only show packages matching a specific keyword like this:

dpkg --get-selections | grep keyword

So for btop, the output looks like this:

Using dpkg to Filter by Package Name
Using dpkg to Filter by Package Name

Once you’ve found the package name, it’s time to uninstall it.

How to Uninstall an Ubuntu Package Using APT

To uninstall a package like btop, I use the following command:

apt remove [package name]

So for btop, the command is:

apt remove btop

If you get a “permissions denied” error, then you need to prefix the commands with “sudo” like this:

sudo apt remove btop

This will ask you for your password, and if you’ve followed the instructions in my linked article on giving users sudo access, then the command will go through. Here’s a screenshot:

Uninstalling a Package in Ubuntu
Uninstalling a Package in Ubuntu

As you can see, we’ve removed the “btop” package!

Purging Packages from Ubuntu Instead of Uninstalling

While using “apt remove” works well, it doesn’t completely remove everything related to the package. It leaves in place configuration files so that if you install the package after removing it, you can pick up where you left off. For many, this is a good thing, but for others, it’s a waste of space. Not everyone likes to have tons of configuration files lying around.

To remove a package along with all its configuration files, use “apt purge” instead. So this will be the command to remove the btop package:

sudo apt purge btop

Remember though, that if you’re temporarily removing a package only to add it back soon after, then it might be beneficial to retain your configuration files so that you don’t lose all your customizations and saved preferences.

Removing Snap Packages on Ubuntu

As explained earlier, Snap packages are a unique innovation where a package comes with all its dependencies installed, so there’s no need to add any repositories. There are a number of useful snap packages – one of which is called “canonical-livepatch”, that allows Canonical to deliver updates to your Ubuntu system without needing to restart the server. This is beneficial for systems that require high availability and uptime.

If you already have a snap package installed on your Ubuntu machine, you can uninstall it using the following command:

sudo snap remove [package name]

Here’s a screenshot of me removing the “btop” package after having installed it as a snap package instead of a regular one:

Removing an Ubuntu Package with Snap
Removing an Ubuntu Package with Snap

It’s easy!

Purging Package with Snap on Ubuntu

Like the apt command, removing a snap package with “snap remove” retains the configuration data of the package in the form of a “snapshot”. These aren’t the direct equivalent of configuration files, but they’re a backup of the configuration files. If you want to remove this snapshot, you first need to obtain the snapshot ID of the package whose configuration data you want gone, and then instruct Ubuntu to forget it.

To obtain the snapshot ID, use the following command:

snap saved

This will list the IDs of all saved snapshots like this:

Get the Snapshot IDs of Removed Snap Packages in Ubuntu.
Get the Snapshot IDs of Removed Snap Packages in Ubuntu.

In the above example, the snapshot ID of the btop snap package is 1. To remove it, we use the “snap forget” command like this:

sudo snap forget [#snapshotID]

Here it is in action:

Snapshot Forgotten
Snapshot Forgotten

And you’re done!

Conclusion

As you can see, uninstalling packages in Ubuntu is easy. Just remember to purge or forget them if you don’t plan to reinstall them, otherwise, they waste space and clutter up your system.

Bhagwad Park Profile Picture
Bhagwad Park

I’m a NameHero team member, and an expert on WordPress and web hosting. I’ve been in this industry since 2008. I’ve also developed apps on Android and have written extensive tutorials on managing Linux servers. You can contact me on my website WP-Tweaks.com!

Related Posts

Echo vs Printf in Bash: What’s the Difference?

Echo and printf can both be used in bash for outputting text. However, echo is for quick output, whereas printf gives you more power.

How to Use Ufw to Open Port 80 in Linux

In Linux, particularly on Ubuntu system, here's how we can use ufw to open port 80. No need to mess with IPTables directly!

All About Bash Parameter Expansion

Parameter expansion in bash is very useful when working with strings like filenames and log entries. It allows you to clean up text.

Linux Process Management: ps, htop, kill, and nice

Linux has a sophisticated toolset to deal with processes in various circumstances from scripting, to monitoring, to control.

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Follow & Subscribe

Exclusive promos, content and more!


Most Popular Posts

NameHero’s Recommended WordPress Plugin and Theme Setup

WordPress Hosting vs. Web Hosting – What’s The Difference?

How To Increase The InnoDB Buffer Pool Size

How To Fix A Stuck All-in-One WP Migration Import

How To Add A Subdomain In Cloudflare

Top Categories

  • WordPress
  • WordPress Tutorials
  • OpenClaw Hosting
  • Enterprise Hosting
  • WooCommerce
  • Web Hosting
  • Resellers
  • Website Security
  • Website Development
  • Website Performance
  • VPS Hosting
  • SEO Tips
  • Announcements
  • Domain Registration
NameHero

NameHero® proudly provides web hosting to over 40,000 customers with 99.9% uptime to over 750,000 websites.

  • Master Card
  • Visa
  • American Express
  • Discover
  • Paypal
Products
  • Web Hosting
  • Managed VPS Hosting
  • Unmanaged VPS Hosting
  • Flex VPS Hosting
  • WordPress Hosting
  • WooCommerce Hosting
  • Reseller Hosting
  • Enterprise Hosting
  • GPU Hosting
  • Email Hosting
  • HeroicGuard
  • Domains
  • Website Builder
  • AI Agent Hosting
Help & Support
  • NameHero Blog
  • NameHero Gaming Blog
  • Support
  • Help Center
  • Migrations
  • Affiliates
  • Gaming Affiliates
  • Call 1-855-984-6263
Company
  • About Us
  • Contact Sales
  • Reviews
  • Uptime
  • We're Hiring

Copyright © 2026 Name Hero, LLC. All rights reserved.
NameHero® is a registered trademark.

  • Privacy Policy
  • Terms of Use
  • Acceptable Use Policy
  • Payment Policy
  • DMCA