macOS Containers and defaults
If Terminal app has Full Disk Access, then
defaults write com.apple.Safariis smart enough to use the preferences file in Safari’s container. But if Terminal does not have Full Disk Access, thendefaultsfalls back to the preferences in the ~/Library/Preferences folder! So if you dodefaults write com.apple.Safari IncludeInternalDebugMenu -bool truewithout Full Disk Access, it’ll write to ~/Library/Preferences/com.apple.Safari.plist, but that has no effect, because Safari is sandboxed and only reads preferences from its own container. Note that this happens even if there’s no old file at ~/Library/Preferences/com.apple.Safari.plist, becausedefaultswill create a new file when necessary.
Previously:
Update (2020-11-02): See also: Dan Moren.