Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I would like to restore LightDM to its default state, because for some reason
/etc/lightdm/unity-greeter.conf is now an empty file.

Deleting /etc/lightdm/unity-greeter.conf and then running sudo apt-get install --reinstall unity-greeter doesn't create a new config file as you might expect.

How can I restore a missing config file?

share|improve this question

3 Answers 3

up vote 41 down vote accepted
  1. Find out what package installed the config file:

    $ dpkg -S unity-greeter.conf
    unity-greeter: /etc/lightdm/unity-greeter.conf
    

    As you can see, the name of the package is unity-greeter.

  2. Rename (or delete) the config file you wish to restore:

    sudo mv /etc/lightdm/unity-greeter.conf /etc/lightdm/unity-greeter.conf.bak 
    
  3. 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>
    
  4. If everything worked as expected, you should get this message:

    Configuration file `/etc/lightdm/unity-greeter.conf', does not exist on system. 
    Installing new config file as you requested.
    
share|improve this answer
2  
Thank you; I have been wondering about this for years. It should really be easier to specify, though - is there a bug open somewhere for that? –  Glyph Oct 11 '12 at 5:35
2  
With --force-confask you could remove step 2. –  bukzor Nov 30 '13 at 4:36
1  
I converted this answer to a little script: gist.github.com/jameshfisher/10547691 –  eegg Apr 12 at 17:45
    
An extra benefit of --force-confask without deleting is that it offers to show the diff between your changes and the original. –  anps Nov 10 at 7:39

Delete (back) the file and and reinstall unity-greeter with apt-get install --reinstall unity-greeter.

share|improve this answer

According to this thread on the Ubuntu Forums, it's as simple as running the following in a terminal:

sudo dpkg-reconfigure lightdm

share|improve this answer
    
I ran that command and this was the output: dpkg-maintscript-helper: warning: environment variable DPKG_MAINTSCRIPT_NAME missing dpkg-maintscript-helper: warning: environment variable DPKG_MAINTSCRIPT_PACKAGE missing. LightDM wasn't restored to its original configuration either. –  Alvin Row Oct 14 '11 at 23:57
    
@DoR: Hm... that's odd. Is reinstalling the package an option. –  Nathan Osman Oct 14 '11 at 23:57
    
I reinstalled it (sudo apt-get --reinstall install lightdm) and still /etc/lightdm/unity-greeter.conf is empty. –  Alvin Row Oct 15 '11 at 1:21
    
This is common advice, but it is definitely wrong; it doesn't work for most cases I've tried it on. –  Glyph Oct 11 '12 at 5:35

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.