8

How do you revert or reinstall a configuration file in Debian/Ubuntu?

I accidentally overwrote the file /etc/bluetooth/main.conf. Running dpkg -S /etc/bluetooth/main.conf shows that the package bluez provides it, but when I run sudo apt-get install --reinstall bluez, it doesn't get reinstalled.

2
  • Related (possibly dupe) unix.stackexchange.com/a/12748/4671 Commented Apr 18, 2016 at 6:56
  • 1
    Lets turn this duplicate arround, this question deals with the more generic problem and has an answer that goes to the point solving the problem stated in the title. Commented Apr 1, 2021 at 11:28

3 Answers 3

10

Solution 1

Run the following command, replacing package-name with the name of the package:

sudo apt-get -o Dpkg::Options::="--force-confmiss" install --reinstall package-name

Solution 2

If you have .deb package then go to that directory where package is exist and run,

dpkg -i --force-confmiss package-name.deb
8

You should mv the file out of the way:

mv /etc/bluetooth/main.conf /etc/bluetooth/main.conf.old
apt-get -o DPkg::options::=--force-confmiss --reinstall install bluez

I don't know if you can get apt to overwrite an existing config file, that's why you should move it out of the way first.

0

Commenting on @Rahul's answer, I found --force-confmiss only works if the configuration file doesn't exist; only then will dpkg install it. If the configuration file has been modified (as described in the question), the following will have dpkg prompt the user to overwrite it:

sudo apt-get -o Dpkg::Options::="--force-confask" install --reinstall package-name
1
  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center. Commented Mar 26 at 0:16

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.