I know how to change privacy settings via GUI (System Settings > Security & Privacy), but I'd like to be able to do it from command line.
What I did to find out
I ran the command:
dconf watch /
to see what changes were made. About the command (from man dconf
):
watch
Watch a key or directory for changes.
Subsequently, I changed settings via GUI to see what happened in the output of the command. It showed:
/org/gnome/desktop/privacy/remember-recent-files false
/com/canonical/unity/lenses/remote-content-search 'none'
/org/gnome/desktop/screensaver/ubuntu-lock-on-suspend false
/org/gnome/desktop/screensaver/lock-enabled false
My question is: how can I use this information to change the settings from command line?
Best Answer
Different ways to edit those settings
The settings you mention are stored in the
dconf
database in~/.config/dconf
(in binary format). This database can either be directly edited withdconf
, or viagsettings
. The difference is explained at the last section of this answer.Once you have the information, posted in your question, you can therefore change the corresponding settings in two different ways.
Using your first example (setting
remember-recent-files
):using dconf write:
or
using gsettings set:
Similarly, reading the current setting:
using dconf read:
or
using gsettings get:
In the first case, you edit the
dconf
database directly, in the latter you are usinggsettings
, which is a CLI frontend to dconf.Which way to prefer; dconf or gsettings?
To protect the integrity of your
dconf
database, in general, it is considered better practice to usegsettings
.Frome this link, we read:
Read more on gsettings and dconf.