‘sudo apt remove’ vs ‘sudo apt purge’

Today’s article is going to cover ‘sudo apt remove’ vs ‘sudo apt purge’ and will be in a different format than some articles. It’s a brief article meant to answer a specific question. It’s nothing more, and nothing less.

The question would be, “What’s the difference between sudo apt remove and sudo apt purge?” It’s a perfectly fine question, thanks. This article will answer it.

It does open up an idea. If you have any questions, you can always just “Ask KGIII” a question. For example, the question prompting this article might be, “What’s the difference between sudo apt autoremove vs sudo apt purge?” It’s a legitimate question, and a good example, of the kinds of questions I’d welcome.

So, for fun, we can pretend someone asked this question! 

If you don’t ask me any questions, I may just have to pretend you did and write my questions and answers all by myself! However, this is the kind of question I’d be looking for. Leave a comment with a question, thanks!

If you lie about your email address to ask a question, that’s fine – just don’t also opt to subscribe to responses. It results in some ‘spammy’ domain behavior and I’d like to avoid that. Use  @example.com, if you want. It should work but there is no example.com of note so bouncing emails won’t be a problem. On the other hand, others can attest to the fact that I’ve sent zero spam messages.

‘sudo apt remove’ vs ‘sudo apt purge’:

In this case, both of these commands are used to remove software from your system. These commands are valid in distros like Debian or Ubuntu, systems that use APT as the package management system. If you want to remove software, the commands would look like one of the following:

With both of these commands, you’ll remove the software. It will not only remove the software, it’ll mark the software as uninstalled in your database of installed applications. This means you can opt to install the software again.

But, there is a difference. When you use, you just remove the software itself. When you use sudo apt purge <package_name>, it not only removes the package, it also removes the configuration files.

In theory, you can do ‘apt remove’ and then re-install the application at a later date while keeping the pre-existing, pre-removal configuration. The regular ‘apt remove’ doesn’t touch configuration files, it only removes those things that were listed as files in the packages manifest and created during the installation process.

So, when you run ‘apt remove’ you’re removing it from your system. When you run ‘apt purge’ you’re making sure (ideally) no traces of it remain. I say “ideally” because it’s not as cut and dry as one might think. Package management isn’t all that smart and things like MySQL will leave behind a user, and other package installs will do similar. 

As a bonus, if you’ve seriously messed up an application’s configuration then you can purge it and have a clean slate, with (ideally) no previous configuration files left over. Of course, if you just use ‘apt remove’ then your configuration files may still exist. If you want to maybe install the application again, and you were happy with the way it was configured, you should use ‘apt remove’. Otherwise, use ‘apt purge’.

If you, like me, are curious as to how the purge command works (it’s not all that intelligent) then click here to learn how the purge command works. The answer is well-written and, more importantly, is correct (inasmuch as I understand). It’s well worth reading, for a better understanding. As I mentioned elsewhere, the package manager isn’t all that intelligent – but it is what it is and it’s much easier than doing it all yourself!

Closure:

And there you have it. You have another article! This one is kinda like a pretend person asked a question and I answered the question in the form of an article. I’d like to do that sort of thing every couple of weeks, but it’d require someone to ask me questions.

I don’t mind if they’re questions I have to research. I think it’d be an interesting new aspect to the site. We can call it ‘Reader Questions’ and maybe give out a prize of some type if your question is chosen. I mean, you shouldn’t need a prize but it might motivate a few of you. Leave a ‘Reader Question’ as a comment on this post and we’ll see how it goes! If it looks like it might work, I’ll add it as a new category.

Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

Linux Tips
Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License.