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.

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.
- Prerequisites and Supported Releases
- Step 1: Finding the Exact Installed Package Name
- Step 2: Method 1: Removing Packages with apt remove (Preserving Configuration)
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.
Comprehensive step-by-step administrator and desktop guide on how to cleanly uninstall software packages on Ubuntu 24.04 LTS and 22.04 LTS. Explains the critical difference between apt remove and apt purge, removing orphaned dependency libraries with apt autoremove, clearing residual configuration files, uninstalling packages managed by dpkg, removing containerized Snap applications, deleting Flatpaks, and using the graphical Ubuntu App Center.
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
sudoadministrative 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.
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/.
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.
Related Ubuntu Tutorials and Documentation
Deepen your Linux system administration skills with our related production-tested guides:
apt Command in Linux: The Complete Package Management Guide— Master comprehensive package management, installation, and search.- How to List Installed Packages on Ubuntu — Query and inspect all software installed on your Ubuntu system.
- Install deb Files on Ubuntu: apt, dpkg, and gdebi — Manage standalone Debian deb packages and dependencies.
Authoritative References and Official Documentation

The Linux Command Line, 2nd Edition: A Complete Introduction
Frequently Asked Questions
Quick answers to common questions and configurations
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.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.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.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.Editorial Disclosure: Website Vidya is supported by our readers. When you purchase hosting, tools, or software through our verified partner links, we may earn an affiliate commission at no extra cost to you. We only recommend solutions we trust and rigorously verify.
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.
Most Read Guides
TrendingUbuntu Server Not Booting? 10 Simple Steps to Fix It Fast
How to Create a 3D Button in HTML and CSS: Easy Steps
How to Install Python and Pip on Ubuntu 24.04 LTS
How to Install Nginx on Ubuntu 24.04
How to Install Python on Ubuntu 24.04 LTS
Related Technical Guides
Tested runbooks, server administration walkthroughs, and troubleshooting guides
Join the Conversation & Perspective
Have thoughts, counterpoints, or reflections on this story? Engage directly with fellow readers and editorial contributors.
No comments on this guide yet. Be the first to share your thoughts or ask a question!