Ubuntu Linux

How to Completely Uninstall Packages in Ubuntu (Using apt & dpkg)

Uninstalling software in Ubuntu isn’t always as simple as clicking “remove.” Leftover dependencies and configuration files can linger, taking up space. Here’s the proper way to cleanly uninstall packages using the terminal.

1. Find the Exact Package Name

Before uninstalling anything, it’s a good idea to find the exact name of the package you want to remove. To do that you can use dpkg -l command:

dpkg -l

This lists all installed packages. To narrow it down, you can use grep. For example, to find Apache-related packages:

dpkg -l | grep apache

2. Uninstall the Package

Use apt remove to delete the package but keep config files:

sudo apt remove [package]

Or a complete removal (including configs), use apt purge:

sudo apt purge [package]

For example:

sudo apt purge apache2

3. Remove Leftover Dependencies

Many packages install dependencies that stay behind. Clean them up with:

sudo apt autoremove

4. Verify Everything is Removed

After uninstalling the package and its dependencies, run the dpkg -l command to make sure the software package you wanted to remove is no longer installed.

5. Manual Cleanup (If Needed)

Some apps (like browsers or OBS Studio) store user configs in ~/.config/. These aren’t removed by apt and must be deleted manually.

Final Notes