How do I clean up my dconf database?

21,498

Solution 1

This is possible using the dconf reset command, though it's not clear if that's a side-effect of a bug.

  • For a single key:

    dconf reset "/path/to/the/key"
    

    Must not end with a /.

  • For a whole path:

    dconf reset -f "/path/to/the/path/"
    

    Must end with a /.

If you do this while having dconf-editor opened, it will likely crash.

Solution 2

If you want to clean the dconf database, you first have to dump the whole dconf configuration via:

morfik:~$ cd ~/.config/dconf/
morfik:~/.config/dconf$ dconf dump / > user-backup
morfik:~/.config/dconf$ ls -al ./user-backup
-rw-r--r-- 1 morfik morfik 30.0K 2015-02-07 08:18:04 ./user-backup
morfik:~/.config/dconf$ rm user

After those steps you have to reopen your graphical session (log out/in). This will create the ~/.config/dconf/user file anew with almost 0 content -- default settings.

As for the user-backup file you had created earlier, it's just a plain text file:

...
[apps/light-locker]
late-locking=false
lock-after-screensaver=uint32 1
lock-on-suspend=true
...

So you can edit it and remove the desired entries/blocks from that file. In other words -- clean it.

When you're done, load it:

morfik:~/.config/dconf$ dconf load / < ./user-backup
morfik:~/.config/dconf$ ls -al ./user-backup
-rw-r--r-- 1 morfik morfik 14.0K 2015-02-07 08:26:23 ./user-backup
morfik:~/.config/dconf$ dconf update /

I think you should restart your graphical session after that again.

And that's it, but you have to remember that all entries that have default values wont be saved -- they will be created anew when some app will ask for it, which is a good thing because you want to backup only the values you had changed.

Share:
21,498

Related videos on Youtube

htorque
Author by

htorque

Updated on September 18, 2022

Comments

  • htorque
    htorque almost 2 years

    Dconf is pretty young, yet my database is already a mess with lots of "schema-less" keys. Is there a way to do some cleaning up, or would I need to start from scratch (by removing ~/.config/dconf/user I guess)?

    • nilsonneto
      nilsonneto almost 13 years
      any chance you can add a screen-shot of what you are seeing? I dont see the same issue.
    • htorque
      htorque almost 13 years
      Use any software that makes use of GSettings/dconf, change one of the default values (eg. gnome-nettool, run a whois), remove the application. You now have the remains in your database (eg. in apps.gnome-nettool). Good if you reinstall that software at a later point, yet I want to remove those keys.
    • Knowledge Cube
      Knowledge Cube almost 13 years
      A quick online search let me find a Google Code project that seems to do something similar for gconf...could this be modified to work with dconf?
    • Severo Raz
      Severo Raz almost 13 years
      Have you tried looking at the text file and attempting a find a replace operaation to remove all the unwanted items from your dconf?
  • Cbhihe
    Cbhihe about 9 years
    This actually does not seem to have any effect whatsoever on the dconf subpath being dumped modified and reloaded. (I work with an fully updated Ubuntu 14.04.2 and try to remove all keys that have to do with the package indicator-netspeed-unity from ppa:fixnix/netspeed.) It looks like a clean way to go about it but just does NOT effect any change.
  • Cbhihe
    Cbhihe about 9 years
    I redid this to be sure, but I confirm this does not effect any change whatsoever. I guess I voted that answer up a little too fast. Can't undo that now.
  • Mikhail Morfikov
    Mikhail Morfikov about 9 years
    I updated the answer, check it -- it works for me.
  • Cbhihe
    Cbhihe about 9 years
    Yes, it now works well. Removing ~/.config/dconf/user before ending your unity session and starting anew were the missing steps. The up-vote stands. Thank you.
  • vanadium
    vanadium over 5 years
    Does not anymore exist in software centre as of Ubuntu 18.04 (and possibly earlier)
  • Zoltán
    Zoltán about 5 years
    This saved me when I got a black screen after logging in to gnome. After opening a tty with Alt+Ctrl+F3, I was able to perform these steps. An additional useful command was sudo pkill -u <username> to restart the active gnome desktop session.
  • Marinos An
    Marinos An about 4 years
    In ubuntu-18 works also. I removed ~/.config/dconf/user. On logout-login it was auto-restoring the file again as it was (from some cache I guess) so I had do the following: 1. Switch to term with Ctl-Alt-1 2. remove the file 3. provide reboot comand on the term. After reboot a: dconf load / < ./user-backup works instantly.
  • Jani Uusitalo
    Jani Uusitalo about 4 years
    I think a warning is warranted: you may be tempted to do a dconf reset -f /, but besides clearing out schema-less keys, reset resets all affected values to their defaults. In any case, I recommend backing up your existing configuration (with dconf dump / >my-dconf.dump) before issuing a dconf reset.
  • jfernandz
    jfernandz over 2 years
    Gconf is deprecated and not the same than dconf.