2

I know I can use this to remove a package but keep configuration:

sudo apt-get remove $package

I know I can also use this to remove a package and discard its configuration files:

sudo apt-get purge $package

But what if I want to keep a package but discard its configuration?

Context: I did something wrong with Network Manager and it's started segfaulting on a loop, and while sudo service network-manager stop works, I also kinda want to use WiFi. If this was just any old boring package, I could just purge and reinstall it. That's obviously not an option for Network Manager, since ubuntu-desktop depends on it.

4
  • Is this what sudo apt-get install --reinstall $package does?
    – badp
    Nov 23, 2015 at 17:02
  • Which configuration do you mean? The configuration, e.g. in /etc or in your home folder? I believe you mean the configuration in your home folder. I'm right?
    – A.B.
    Nov 23, 2015 at 17:09
  • @A.B. I don't know where NM stores its configuration to be entirely honest with you, but I know that install --reinstall was sufficient to stop the desperate segfaulting, at least until I tried to reconnect with the offending WiFi network again.
    – badp
    Nov 23, 2015 at 17:23
  • Yes, therefore install --reinstall in my answer. ;)
    – A.B.
    Nov 23, 2015 at 17:36

1 Answer 1

4

To reinstall the package and overwrite the changed configurations in /etc with the configuration of the package run

sudo apt-get -o Dpkg::Options::="--force-confnew" install --reinstall package_name

But this command doesn't affect configurations in your home folder, because nothing in the home folder will be changed by the package manager.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .