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:
Property List Editor is a graphical ap that’s a part of the Xcode developer tools. You can get the Xcode tools from developer.apple.com. Property List Editor is most useful if you already understand property lists and their conventions.
PlistBuddy
is a command-line tool for directly reading and modifying values inside a property list without the need to convert the property list to an intermediary format.
defaults
is a command-line tool that you can use to edit property lists. The defaults
command is a powerful tool, with functionality beyond simple editing of property lists. When you know the specific key and value in a property list that you need to change, it’s very efficient.
plutil
is a command-line tool that you can use to change a property list into a format you can edit with a text editor, then change back to its binary format.
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:
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
Enter the following command to enter the PlistBuddy
interactive mode:
PlistBuddy /Users/alecjones/Library/Preferences/com.apple.Dock.plist
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.
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.
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.
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.
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.)
Enter the values following the defaults
command:
defaults write com.apple.dock orientation left
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.
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.
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.
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:
Convert the file back to binary format:
plutil -convert binary1 com.apple.dock.plist
For information about Property Lists, see the plist
man page.