The Right Way to Remove Apt, Deb, Snap, and Flatpak Packages on Ubuntu

Apt package manager, .deb file, snap store, and flatpak are the recognized ways to install a package on Debian-based distributions such as Ubuntu and PopOS.

Many people get confused about finding an appropriate method to remove a package from the system. For example, apt remove and apt purge is the standard method of removing packages from the Ubuntu system.

Without much clarity, people randomly use this command to remove packages without understanding the working process of these commands.

Today, you are about to learn the correct way to remove a package on Ubuntu and other Debian-based distributions by understanding the meaning behind all the commands.

Removing Packages Installed via Apt Package Manager

Apt package manager provides the easiest way to install any package available in the repository. To perform the installation process, you need to execute the apt install [appname] command with or without sudo, depending upon user privileges.

After the installation process is done, you have two methods to remove the installed package, as mentioned below.

Apt remove command

The apt remove command comes into the picture at the time of eliminating package binaries. It will skip the configuration or data files of the package from deleting along with the dependencies installed with it at the installation time.

If you made any changes in the package configuration or settings, it would be untouched. In the future, if you reinstall the same package, it will pick up the existing configuration or data files.

Note: Package removal may require root account or sudo access.

Syntax

$ apt remove [PACKAGENAME]

For example: if you want to remove the Nginx web server, replace the package name with Nginx.

$ apt remove nginx

Apt purge command

Apt purge and apt remove command has the same functionality except, apt purge also eliminates the configuration and data file of the package along with the binaries and dependencies installed with it at the time of installation.

All the changes made in the configuration will be wiped out without leaving anything behind.

Note: Use this command if you sure to not going to use the target application in the near future.

Syntax

$ apt purge --auto-remove [PACKAGENAME]

Above command remove everything along with the dependence, --auto-remove is an alias of autoremove command work similarly to apt autoremove command.

For example: if you want to remove the Nginx web server, replace the package name with Nginx.

$ apt purge --auto-remove nginx

Removing Applications Installed via the .deb File

The package installed via the .deb file can be easily removed using apt remove, apt purge or dpkg --remove package name.

If you don’t know the package name, search for it using the below command.

$ apt-cache search [YOURAPP]

Replace the [YOURAPP] with your app name or something specific to your app. For chrome, it will be a browser.

$ apt-cache search browser

After finding the package name, use any of the below methods to remove it from your system.

$ apt remove google-chrome-stable

Apt Remove will remove all the binaries of the chrome browser except configuration and data files.

$ apt purge google-chrome-stable

Apt Purge will remove all the binaries of the chrome browser, including configuration and data files.

If you could not find the package name, you can still easily remove the package using its .deb file with the dpkg command as shown below.

$ dpkg -r ./google-chrome-stable_current_amd64.deb

Removing Applications Installed via Snap Store

Snap store is the better alternative to apt command due to its bundle feature to pack everything inside a single snap file. This makes it easier for a developer to develop an application and for user to install it.

Note: Package removal may require root account or sudo access.

Syntax

$ snap remove [SNAP-PACKAGE]

Replace the [SNAP-PACKAGE] with your package name.

For example: execute the below command to remove OBS studio from your system installed via the snap store.

$ snap remove obs-studio

After the removal is completed, you will find the OBS Studio snap package has been removed. However, the folder of the OBS is still present in the snap directory. To remove it, execute the below command.

$ rm -r ~/snap/obs-studio

Removing Applications Installed via Flatpak

Flatpak and Snap Store share the common interest of including everything inside a single bundle, except that snap is maintained by canonical, and flatpak is an entirely community-driven project.

Syntax

$ flatpak uninstall [PACKAGEID]

For example: if you want to remove Spotify installed via flatpak, specify the Spotify application id to remove it from your system, as shown below.

$ flatpak run com.spotify.Client

Final Word

If you are still struggling to remove the installed packages from your system, drop the package name along with the installation medium in the comment section for your help.

Leave a Reply