Specifications
Chapter 5 Common Command-Line Tasks 37
 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, and then change back to its binary format.
Using PlistBuddy to edit property lists
The PlistBuddy command is designed 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 specic property list les.
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 in 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
See “Executing Commands and Running Tools” on page 13 .
If the le you’re trying to edit doesn’t exist, PlistBuddy creates the le in the
designated location.
3 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
4 Save and exit:
Save
Exit
PlistBuddy
can also be run non-interactively. To make the same change without
invoking interactive mode:
/usr/libexec/PlistBuddy -c "Set :orientation left" ~/Library/Preferences/
com.apple.Dock.plist
Both examples above assume the orientation key already exists. This isn’t necessarily
true for a new user in Mac OS X version 10.6. Don’t assume that a value exists. First,
conrm it with the Print command. Otherwise, you need to use the Add command,
which also requires designating a type.