Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to know the default value of a dconf/gsettings key.

My question is a followup of the question below: Where can I get a list of SCHEMA / PATH / KEY to use with gsettings?

What I'm trying to do, so create a script that reads all my personal preferences so I can back them up and restore them. I plan to iterate though all keys, like the script above, see what keys have been changed from their default value, and make a note of these, that can be restored later.

I see that the dconf-editor display the keys' default value, but I'd very much like to script this. Also, I don't see how parsing the schemas /usr/share/glib-2.0/schemas/ can be automated. Maybe someone can help?

gsettings get-default|list-defaults would be nice =)

(Geesh, it was much easier in the old days where you just kept your ~/.somethingrc in subversion ... =\

Based on the answer given below, I've updated the script to print schema, key, key's data type, default value, and actual value:


for schema in $(gsettings list-schemas | sort); do
    for key in $(gsettings list-keys $schema | sort); do
        type="$(gsettings range $schema $key | tr "\n" " ")"
        default="$(XDG_CONFIG_HOME=/tmp/ gsettings get $schema $key | tr "\n" " ")"
        value="$(gsettings get $schema $key | tr "\n" " ")"
        echo "$schema :: $key :: $type :: $default :: $value"

This workaround basically covers what I need. I'll continue working on the backup scrip from here.

share|improve this question
up vote 5 down vote accepted

There does not seem to be a nice way to get at the default values directly, but since the client checks XDG_CONFIG_HOME in the environment a decent workaround to get values from a fresh config might be:

XDG_CONFIG_HOME=/nonexistent gsettings get SCHEMA KEY
share|improve this answer
Thanks! Good workaround! – Zta Oct 5 '12 at 20:47

If you are interested in backing up and restore your settings (in this case you should change the title of your question).


You can backup your settings with

gsettings list-recursively > backup

This writes all keys to the file backup in you Home-Folder.


As far as I know there isn't any direct option to import the file back to dconf. Maybe you could write a routine that reads the backup file line by line and executes gsettings set <input line from backup> to restore your settings.

share|improve this answer

Your Answer


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.