Edit property lists

Preference and configuration files in OS X use property lists (plists) to specify the attributes, or properties, of an app or process. An example is the Finder’s preferences plist in the Library/Preferences/ folder of a user’s home folder. The file is named com.apple.Finder.plist. The default naming convention for a plist includes the distributor’s reverse DNS name prepended to the app or process name, followed by a “.plist” extension.

Property lists are binary files that you can edit using the following tools:

Use PlistBuddy to edit property lists

The PlistBuddy command is designed to allow you to easily read and modify values in a property list. If you know the values to set or read, you can quickly make changes with PlistBuddy. PlistBuddy works on specific property list files. This example shows how to use the PlistBuddy command interactively to change the orientation of the Dock for a local user:

  1. Determine the names of the appropriate property list, key, and values. In this case, the name for the Dock’s property list is com.apple.Dock.plist. If you were editing the Dock property list for the user alecjones, the path would be:

    /Users/alecjones/Library/Preferences/com.apple.Dock.plist
  2. Enter the following command to enter the PlistBuddy interactive mode:

    PlistBuddy /Users/alecjones/Library/Preferences/com.apple.Dock.plist
  3. If the path to PlistBuddy isn’t in your default paths, you need to add it or explicitly call it as follows:

    /usr/libexec/PlistBuddy ~/Library/Preferences/com.apple.Dock.plist.

    If the file you’re trying to edit doesn’t exist, PlistBuddy creates the file in the designated location.

  4. In interactive mode, you can choose from many commands. To set or change the orientation of the Dock to the left side of the screen, enter: Set :orientation left.

  5. Save and exit:

    Save Exit

PlistBuddy can also be run non-interactively. To make the same change without invoking interactive mode, enter the following command:

/usr/libexec/PlistBuddy -c "Set :orientation left" ~/Library/Preferences/ com.apple.Dock.plist

Both examples above assume the orientation key already exists.

You should never assume a value exists. Before you use the PlistBuddy command, confirm that a value exists with the Print command it displays all the key values that exists. If it doesn’t exists, use the Add command to add the value to the key and designate a type.

There are many other options for PlistBuddy that are invoked in a similar manner. For information about PlistBuddy, see its man page.

Use the defaults command to edit property lists

The defaults tool works directly with the OS X preferences subsystem and is used by many apps in OS X to manage preferences and other settings. It can be built into shell scripts and lets you access preferences in the multiple domains that exist on a given computer.

  1. Determine the names of the appropriate property list, key, and values. For example, the name for the Dock’s property list is com.apple.Dock.plist. (When invoking the defaults command, omit the .plist extension.)

  2. Enter the values following the defaults command:

    defaults write com.apple.dock orientation left
  3. In most cases, you need to restart the app or process. A simple way to do this is to use Activity Monitor to select the appropriate process, then click Quit Process. For this example, you would choose the process named “Dock.”

For information about defaults, see its man page.

Use plutil and a text editor to edit property lists

Before making any changes to plist files using plutil, make a backup copy of the files. Do this in the Finder, or use the cp command:

cp com.apple.dock.plist com.apple.dock.plist.bak

In OS X v10.6 or later, plist files are stored in a binary format. If you want to edit them with a text editor, you must first convert them to plain text.

  1. Convert the plist file to plain text using the plutil command:

    plutil -convert xml1 com.apple.dock.plist

    This results in an XML text file that you can edit with a text editor.

  2. Before making any changes to plist files using plutil, make a backup copy of the files. Do this in the Finder, or use the cp command:

  3. Convert the file back to binary format:

    plutil -convert binary1 com.apple.dock.plist

For information about Property Lists, see the plist man page.