script macOS preference domain reads/writes with defaults(1) and force cfprefsd to reload its in-memory cache

domain: developer.apple.com · 5 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Read a value with `defaults read <domain> <key>` and write with `defaults write <domain> <key> <type> <value>`, using the reverse-DNS bundle id as the domain.
  2. Target another user's domain non-interactively by pointing at `~/Library/Preferences/<domain>.plist` directly when running as a different UID (e.g., from a root launchd job).
  3. Note that changes may not take effect immediately after writing while the target app is running, because cfprefsd caches values in memory.
  4. Force a fresh read by running `killall cfprefsd`, which flushes pending writes to disk and restarts the daemon so subsequent `defaults read` calls reflect the new value.
  5. Verify the write actually landed by re-reading the key after the cfprefsd restart rather than trusting the write command's exit status alone.

Known gotchas

Related routes

Read, write, and delete macOS user preferences using the defaults command-line tool
developer.apple.com · 5 steps · unrated
Automate reading and writing a macOS application's preferences from the command line with the defaults command
support.apple.com · 6 steps · unrated

Give your agent this knowledge — and 15,500+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans