Website Vidya
Linux & ServersStep-by-Step Guide

How to Uninstall Software Packages on Ubuntu

Learn how to uninstall software packages on ubuntu using apt remove, apt purge, autoremove, dpkg, snap remove, flatpak uninstall, and clean orphan files.

RR
Rajesh RayLead Systems Educator
Published:
5 min read
PDF Cheat Sheet
How to Uninstall Software Packages on Ubuntu
AI Executive SummaryWebsiteVidya AI

5 min read

Learn how to uninstall software packages on ubuntu using apt remove, apt purge, autoremove, dpkg, snap remove, flatpak uninstall, and clean orphan files.

Key Highlights
  • Prerequisites and Supported Releases
  • Step 1: Finding the Exact Installed Package Name
  • Step 2: Method 1: Removing Packages with apt remove (Preserving Configuration)
Grounded in full engineering runbookWebsiteVidya AI Engine

Installing software on Ubuntu is effortless, but over months of development, testing, and system administration, servers and workstations accumulate obsolete applications, unused libraries, and orphaned dependencies.

These leftover packages consume valuable disk space, clutter system configuration directories in /etc/, slow down package manager operations, and expand the system's potential security attack surface.

Ubuntu accommodates multiple package formats—traditional Debian APT/dpkg packages, Canonical Snaps, Flatpaks, and custom source builds—each requiring specific removal techniques.

In this guide, we walk through how to uninstall software packages on ubuntu cleanly across all package ecosystems, safely purge residual configuration files, and reclaim lost disk storage.

Advertisement

Prerequisites and Supported Releases

This guide is thoroughly verified on Ubuntu 24.04 LTS (Noble Numbat) & Ubuntu 22.04 LTS. The instructions apply cleanly to cloud instances (AWS EC2, Google Compute Engine, DigitalOcean, Hetzner), bare-metal servers, and local virtual machines.

Before proceeding, ensure you have the following requirements satisfied:

  • A computer or server running Ubuntu 24.04 LTS, Ubuntu 22.04 LTS, or any Debian-based system.
  • A non-root user account with sudo administrative privileges for system-level removals.
  • Access to a command-line terminal shell.

Step 1: Finding the Exact Installed Package Name

Before uninstalling any software via the command line, you must determine its exact internal package name.

Advertisement

Package names in APT frequently differ from their commercial brand names or executable command names.

Use apt list --installed or dpkg -l combined with grep to identify the exact package identifier:

# Search installed packages matching a name keyword (e.g., apache or nginx):
apt list --installed | grep -i "apache"

# Locate the package that owns a specific binary command:
dpkg -S $(which nginx)
# Output confirms: nginx-core: /usr/sbin/nginx

Step 2: Method 1: Removing Packages with apt remove (Preserving Configuration)

The standard command for uninstalling Debian packages is apt remove.

When you run apt remove, APT deletes the program's binary executables, manpages, and library files, but intentionally preserves global configuration files in /etc/.

Advertisement

This is the preferred method if you plan to reinstall or upgrade the software in the future and wish to keep custom configurations intact:

# Remove package binaries while preserving custom configuration files:
sudo apt remove nginx

# Remove multiple packages in a single command:
sudo apt remove apache2 php mysql-server

Step 3: Method 2: Purging Packages and Configuration with apt purge

If you want to eliminate an application entirely—including all custom settings, logs, and configuration files in /etc/—use apt purge.

Purging ensures that no residual configuration files remain to conflict with future software or clutter your filesystem.

Execute apt purge in your terminal:

# Purge application binaries and global configuration files completely:
sudo apt purge nginx

# Purge packages previously removed with 'apt remove' that left residual configs:
dpkg -l | grep "^rc" | awk '{print $2}' | xargs sudo apt purge -y

Step 4: Method 3: Cleaning Orphan Dependencies with apt autoremove

When you install an application (such as a desktop media player or database server), APT automatically installs dozens of shared libraries and helper packages as dependencies.

When you subsequently remove the primary application, those dependent libraries are not automatically deleted because other software might conceivably share them.

The apt autoremove command scans your system, detects libraries that are no longer required by any installed application, and safely deletes them:

Combine with --purge to delete residual configuration files from orphaned dependencies as well:

# Remove orphaned dependencies no longer needed by any package:
sudo apt autoremove -y

# Remove orphaned dependencies AND their configuration files:
sudo apt autoremove --purge -y

# Clear the local APT download archive cache (/var/cache/apt/archives/):
sudo apt clean

Step 5: Method 4: Uninstalling Snap Packages

Ubuntu 24.04 and 22.04 distribute many popular desktop applications (such as Firefox, Chromium, and Spotify) as containerized Snap packages.

Standard APT commands cannot remove Snap packages because Snaps are managed independently by the snapd daemon.

List installed Snap packages and remove the target application using snap remove:

# List all installed Snap packages:
snap list

# Remove a specific Snap package (e.g., firefox or vlc):
sudo snap remove firefox

# Remove a Snap package without creating a backup snapshot (faster):
sudo snap remove --purge firefox

Step 6: Method 5: Uninstalling Flatpak Applications

If you configured Flatpak and Flathub on your Ubuntu workstation, manage and remove Flatpak applications using the flatpak uninstall command.

List installed Flatpaks and execute the removal command:

Clean up unused Flatpak runtime runtimes with --unused:

# List installed Flatpak applications:
flatpak list --app

# Uninstall a specific Flatpak application:
flatpak uninstall org.videolan.VLC

# Delete unused Flatpak runtime dependencies:
flatpak uninstall --unused -y

Troubleshooting and Common Errors

When configuring Ubuntu servers, unexpected permission errors, network timeouts, or lock contention can occur. Review these common issues and verified resolutions:

E: Could not get lock /var/lib/dpkg/lock-frontend - open (11: Resource temporarily unavailable)

Cause: Another process (such as unattended-upgrades or Ubuntu Software updater) is currently using APT.

Resolution: Wait a minute for the background task to complete, or identify the process using sudo lsof /var/lib/dpkg/lock-frontend.

sudo lsof /var/lib/dpkg/lock-frontend

Package [name] is not installed, so not removed

Cause: The package name specified in the command is misspelled or differs from the internal package name.

Resolution: Find the exact package name with dpkg -l | grep -i [keyword].

dpkg -l | grep -i [keyword]

snap 'package' is not installed

Cause: Attempting to remove an APT package with the snap command, or vice versa.

Resolution: Check whether the package was installed via Snap (snap list) or APT (dpkg -l).

snap list

Security Best Practices and Hardening

Always inspect the list of packages flagged for removal before confirming an apt remove command to avoid accidentally uninstalling critical meta-packages (like ubuntu-desktop).

Do not execute arbitrary removal scripts from third-party websites without reading their contents.

Regularly run apt autoremove --purge on cloud servers to eliminate unpatched, obsolete library versions.

Deepen your Linux system administration skills with our related production-tested guides:

Authoritative References and Official Documentation

Frequently Asked Questions

Quick answers to common questions and configurations

4 FAQs
apt remove uninstalls program binaries and documentation while preserving user and global configuration files in /etc/. apt purge deletes both the binaries and all configuration files permanently.
No. Neither apt remove nor apt purge touches personal files or application settings stored in your home directory (e.g., in ~/.config/ or ~/.local/). You must delete those personal folders manually if desired.
In dpkg -l, the status rc indicates that the package was Removed, but its Configuration files remain on disk. You can purge them with dpkg -l | grep '^rc' | awk '{print $2}' | xargs sudo apt purge -y.
While possible, removing snapd is not recommended on Ubuntu Desktop because standard packages like Firefox and Chromium depend on it. On servers, run sudo apt purge snapd after removing all active snaps.
RR
Written byVerified Author

Rajesh Ray

I’m Rajesh Rai, a full-stack developer, Linux administrator, and technology enthusiast passionate about making complex technology easier to understand and use.

SPAM-FREE MODERATED DISCOURSE

Join the Conversation & Perspective

Have thoughts, counterpoints, or reflections on this story? Engage directly with fellow readers and editorial contributors.

AT
MP
JV
+2

No comments on this guide yet. Be the first to share your thoughts or ask a question!

Recommended Reading10 Guides

Related Technical Guides

Tested runbooks, server administration walkthroughs, and troubleshooting guides

Featured Infrastructure PartnerUp to 75% OFF + 3 Months Free

Supercharge Your Linux & Cloud Workloads with Hostinger

Deploy high-speed NVMe KVM VPS, Docker containers, and LiteSpeed-accelerated WordPress servers in under 60 seconds with full root access, dedicated IPv4, and 24/7 technical support.

Pure NVMe SSD StorageFull Root Access & SSHFree Domain & Unlimited SSL99.9% Uptime SLA
Plans from$2.99/mo
Claim Hostinger DealAffiliate link • Special discount applied at checkout