I recently migrated to a new Macbook.
If I do a $ defaults write ...
in my shell, I get an error shaped like defaults[12608:79345] Could not write domain Apple Global Domain; exiting
. Using sudo
does work, however I have some defaults that are set in my .bashrc file — these writes did work in my old system's .bashrc, without a sudo.
Q1: Are defaults saved across reboots? If so, I can removed these from my (cluttered) .bashrc and get on with life.
Q2: If defaults are not saved across reboots, what file(s) do I need to chown or chmod in order to get the defaults write
to work quietly, in my .bashrc file?
What I've done so far:
- Read the
defaults
man page — only seems to document the API. - Skimmed around in Apple's developer docs for Preferences. Again, this seems to be higher level API documentation for application developers who are using Cocoa.
Best Answer
The
defaults
command normally writes an entry into the relevant.plist
file. The whole point of property list files is to retain settings between boots. You should not need to re-apply them after each boot.Consequently, you should not need to run the defaults command in a
.bashrc
file, which runs at the start of every interactive shell session.You should not need sudo for defaults commands such as these:
If you're trying to write some other type of
default
command to a system-level domain, then that might explain why you needsudo
. Otherwise, the need forsudo
is 'unexpected'.