apt remove vs apt purge: What's the Difference?

apt remove and apt purge are two similar commands used for uninstalling applications in Ubuntu and Debian. So, what's the difference?
Warp Terminal

To uninstall an application in the Ubuntu terminal, you can use:

sudo apt remove package_name

But in various forums, you may come across the suggestion to use the apt purge command for removing applications completely.

This leaves you confused because using apt purge is quite similar to apt remove:

sudo apt purge package_name

So, why are there two similar commands for removing packages? What’s the difference between the two? Let me explain it to you with a few examples.

What’s the difference between apt-remove and apt-purge?

Both apt-remove and apt-purge do the same thing and that is to uninstall a package. The apt-purge removes the package and purges any configuration files associated with it. That’s the only difference between the two. Neither command touches the application files under the home directory of the user.

Have you ever removed an application and installed it again, only to notice that all your settings are in place? It’s because the apt remove command doesn’t remove the configuration files.

See what’s being removed and what remains

Let me share a practical example of removing the mplayer application using both apt remove and apt purge commands. The focus is on seeing what files remain after each operation.

Here are the files associated with MPlayer before removal.

mplayer before removal
Files associated with mplayer

Now, if I run the apt remove command.

apt uninstall package ubuntu
Using apt remove to uninstall mplayer

Here are the files that remain in the system:

files after mplayer removal
Files remaining after mplayer removal

As you can see, there are mplayer files remaining in two locations: /etc and /home/abhishek.

Now, if I install mplayer again and use apt purge to remove the mplayer application this time.

apt purge command
Using apt purge command to remove mplayer

Let’s look for files associated mplayer now.

files after mplayer removal
Files remaining after purging mplayer

As you can see, the files from /etc directory no longer exist.

But what about the files in the home directory? Should apt purge not remove it?

The answer is negative. The apt commands do not touch the configuration files in the home directory. They remain in the system unless you manually remove them. Those files are really small in size and hardly take up disk space.

Do note that not all applications create configuration files under /etc or home directory.

The effect of using apt remove or apt purge

A practical example I can think of is Discord. You install Discord on Ubuntu with deb file. Start using it by logging into your account. Remove Discord and install it again using deb file.

Now if you start Discord, you’ll notice that you are already logged into your account. Surprising, no?

But this is a feature because some applications like Discord, VirtualBox provide you updates similarly. You remove the current version and install the newer one (even if you don’t see this process). Since the application configuration files are not touched, you are logged back in without additional effort.

The apt remove command allows you to reuse an application with a similar configuration that you used in the past.

However, you may not always want it. If you configured an application in a bad way and want to start from scratch, the apt purge command is the way to go forward.

Does apt purge perform a wild-card removal?

When you purge a package, you’ll notice that it mentions removing package-name*. This indicates that it will remove all the packages with names starting from package-name.

apt purge wild card
apt purge wild card

I didn’t find a definite answer on this point in the documentation (i.e. man page). So, I did a little test on my own. I installed espeak and espeak-ng packages. The espeak* should expand to espeak-ng as well.

But when espeak was pruged, the `espeak-ng package was untouched. So there seems to be a mechanism that protects against such wild card expansions.

So, should you use apt remove or apt purge?

Few people just get addicted to using apt purge.

In my opinion, apt remove is what you should use most of the time. Use apt purge when you have to get rid of the custom configuration files.

In both cases, you’ll have to remove the remaining configuration files from the user’s home directory and run apt autoremove to eliminate any leftover dependencies.

Over to you now. Do you understand the difference between apt remove and apt purge better now? Which one do you prefer to use?

Learn more on apt commands and package management

Both of these remove and purge options are a couple of options of the apt command. You should read more about using the apt command for package management.

Using apt Commands in Linux [Complete Guide]
Brief: This article shows you how to use apt commands in Linux with examples so that you can manage packages effectively. If you are using Debian, Ubuntu, Linux Mint or any other Debian or Ubuntu based distributions, you must have come across some apt commands by now. First noticed in

apt is just a newer and smaller subset of the apt-get command. It is meant for the end users. Here are the differences between the two.

Difference Between apt and apt-get Explained
Brief: This article explains the difference between apt and apt-get commands of Linux. It also lists some of the most commonly used apt commands that replace the older apt-get commands. One of the noticeable new features of Ubuntu 16.04 was the ‘introduction’ of apt command. The reality is that

The sources.list files are a crucial part of the apt package management. Here are the essentials you need to know about it.

What is the Use of sources.list File in Ubuntu Linux?
Understanding the concept of sources.list in Ubuntu will help you understand and fix common update errors in Ubuntu.

The more you know, the better you understand the mechanism of your Ubuntu system. Never stop learning.

About the author
Abhishek Prakash

Abhishek Prakash

Created It's FOSS 11 years ago to share my Linux adventures. Have a Master's degree in Engineering and years of IT industry experience. Huge fan of Agatha Christie detective mysteries 🕵️‍♂️

It's FOSS

Making You a Better Linux User

It's FOSS

Great! You’ve successfully signed up.

Welcome back! You've successfully signed in.

You've successfully subscribed to It's FOSS.

Success! Check your email for magic link to sign-in.

Success! Your billing info has been updated.

Your billing was not updated.