Apple - Is there any way to save Mac OS X preferences into a shell file?

The System Preferences appear to be stored in various places, depending on whether they are user or system specific. A lot of them are stored in either /Library/Preferences/ or $HOME/Library/Preferences/ (for per-user settings). But each preference pane will have its own way of storing them.

You can see which preferences are stored this way by typing:

defaults read <domain>

Where <domain> is either the start of the filename in your per-user system preferences, or the full path to a .plist file. For example:

defaults read com.apple.screensaver
defaults read /Library/Preferences/com.apple.screensaver

The former will show your per-user customisation of the screensaver settings, while the latter will show the system screensaver settings.

The settings are largely organised by preference pane, though not necessarily that straight forward. You'll likely have to poke around in /Library/Preferences and sub-folders (especially SystemConfiguration) to find them all.

One option would be to just copy the relevant files out, and put them back in place for new installations.

Another way would be to export and import it as required.

Exporting the Power Management (Energy Saver) System Preferences to pm.plist:

defaults export /Library/Preferences/SystemConfiguration/com.apple.PowerManagement pm.plist

Importing those preferences from pm.plist on the new computer:

defaults import /Library/Preferences/SystemConfiguration/com.apple.PowerManagement sysprefs.plist

You may even want to edit the various exported .plist files if there are specific system preferences you do/don't want to share between computers. That way you can have some customisation locally, and the import command will not overwrite those, just add the ones you've set in the .plist files. You can use the defaults command to modify your own .plist files as well (but make sure you specify the full path to the file, not just a name, or you may be modifying your per-user preferences).


Automatically producing a script to make all the required changes is well nigh impossible. Mac system administrators spend many hours in dark bars drinking beer or bourbon and swapping bits of these files - we are reluctant to share all that work unless you are prepared to pick up the tab.

Actually the easiest way to capture the config changes is to use snapshotting.

Grab a copy of InstallEase and snapshot your new Mac. Now do all the configuration that you want and you can take another snapshot and build an installer that will install the changed files into a new Mac.

Of course complications can arise when applying the changes to a new version of the operating system but that's why we drink the bourbon.


The last time I did a clean reinstall I just copied the whole ~/Library/Preferences/ folder, and I didn't run into any issues because of it. Settings for old versions of applications and Mac-specific settings should just be ignored. There are almost no files in ~/Library/Preferences/ on a new installation, and if you delete all files in ~/Library/Preferences/, the preference files will be recreated when they are needed.

The preference files for sandboxed applications are now stored in ~/Library/Containers/, but I don't know if copying it to another Mac would cause any issues.

You might also just use Migration Assistant.

Or if you go the .osx route, you can diff the output of defaults read:

  1. Run defaults read|awk 'length<200'>/tmp/a
  2. Change some settings
  3. Run defaults read|awk 'length<200'>/tmp/b;diff /tmp/[ab]

You can run sudo opensnoop or use fseventer to see what files are modified when you change preferences from the GUI.