‘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.

Last Updated on December 14, 2023 by KGIII

Subscribe to Newsletter!
Get notified when new articles are published!
We promise to never share your email!
icon

Author: KGIII

Retired mathematician, residing in the mountains of Maine. I may be old and wise, but I am not infallible. Please point out any errors. And, as always, thanks again for reading.

8 thoughts on “‘sudo apt remove’ vs ‘sudo apt purge’”

    1. LOL Thanks for your feedback! Hundreds of thousands of visitors suggest it’s not that bad, but you’re absolutely welcome to think that. (You’re almost certainly the troll from Linux.org earlier today.)

      I bet you didn’t think I’d publish this? Well, I did. You’re entitled to your opinion – but you’re not entitled to troll. So, you’ve said your piece. Move on and be an adult about it.

  1. Thank you for your articles. I am new to Linux and read them as soon as they come to my email. I recommended you to others. One article every day or two is a perfect pace for those are not students and have other activities demanding their time. I am enjoying Linux (Mint Cinnamon.)
    I bought a Framework DIY Laptop and downloaded the OS myself. I expect to be in it for the long haul and this is an ongoing project for me.
    I have to say that the best part of my experience so far is the wealth of information and support available. I’m not just a user of a new system, I’m a member of a community! There is a lot to love about Linux.
    Microsoft and Apple are so impersonal, in comparison.
    Keep up the good work!

    1. Thanks! I’m always happy to help where I can.

      Because Linux isn’t a giant conglomerate, but is a community, I feel obligated to give back to that community – especially because the community has given me so much.

  2. Loved the article. I’m not much of a subscriber, but will subscribe the newsletter to try it out. Thank you.

    1. There’s no spam and it just tells you that there’s a new article posted.

      Thanks for subscribing! There’s an unsubscribe link in every email should you change your mind.

      Your email address will never be used outside of that.

Leave a Reply

Your email address will not be published. Required fields are marked *

Subscribe To Our Newsletter
Get notified when new articles are published! It's free and I won't send you any spam.
Linux Tips
Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License.