I keep hearing that if any of my programs start to act oddly within Mac OS X that one culprit can be the preferences file for that particular program. That’s all well and good, but what if the corrupted preferences file is messing up things I can’t see? Surely there’s some way to check or verify the preference files to ensure all is well?
A fascinating question, because I too have been wondering about the mysterious new XML-format “plist” files in Mac OS X and how to ascertain if any of them are messed up without having the associated application start spitting up bits.
It turns out that there’s a great little command-line application accessible within Terminal (Applications -> Utilities -> Terminal) that performs just what you seek, a plist verification program called plutil.
At it’s most basic you can just hand it a suspect preferences file and it’ll scan it to see if all is well with the overall XML format. The program doesn’t know how a given application interprets its preferences, so if a ‘true’ should be ‘false’ that won’t be flagged, of course.
$ cd ~/Library/Preferences $ plutil com.microsoft.Word.plist com.microsoft.Word.plist: OK $
You can replace the individual plist name with a set of all plist files in the Preferences directory with “*.plist” instead, as in: plutil *.plist. If you try this, however, you’ll find that it has a status output line for each file checked which means that you lose the problems in the stream of successes.
To avoid this problem, plutil has another flag, ‘-s’, that specifies you should only be shown errors. Now we’re getting somewhere! Here’s what happens on my computer when I run this:
$ plutil -s *.plist IM_Installer.plist: stream had too few bytes com.Intego.NetUpdateInstaller.plist: stream had too few bytes com.apple.NetInfoManager.plist: stream had too few bytes com.apple.mix.plist: Conversion of data failed. The file is not UTF-8, or in the encoding specified in XML header if XML. com.realmacsoftware.buttonbuilder.plist: XML parser error: Unexpected character T at line 1 Old-style plist parser error: Unexpected ';' or '=' after key at line 2
Not too good. Well, actually there are 244 plist files in this directory (use ls *plist | wc -l to figure that out for yourself) so hiccups with four or five probably isn’t too bad.
The standard way to fix a corrupted preferences file is to just delete it and then reset any custom settings in that specific application next time it’s launched. So I’ll do that, but not by typing in the filenames. How terribly… archaic! Instead, I’ll use the helpful Mac OS X shell backquote feature to run the test against all the preferences files again, then extract just the filenames:
$ rm -i `plutil -s *.plist | grep 'plist:' | sed 's/://g'` remove IM_Installer.plist? y remove com.Intego.NetUpdateInstaller.plist? y remove com.apple.NetInfoManager.plist? y remove com.apple.mix.plist? y remove com.realmacsoftware.buttonbuilder.plist? y
Notice that the inclusion of the ‘-i’ flag to rm causes the program to prompt me before each file is deleted. A nice safety trick!
If you’re thinking we’re done, you’re not quite correct. There’s a second directory full of plist files, the system Library at /Library:
$ cd /Library/Preferences $ sudo plutil -s *.plist Password: com.Logitech.ControlCenter.plist: stream had too few bytes $
This time you’ll want to use the sudo command to make sure that the plutil command can read even those preferences files that are only readable by the administrator. For completeness sake, natch!
If there are any preference files in the results that you want to trash, you’ll probably need to use sudo rm rather than just rm.
Phew. Long answer for what seems like a simple question. Hope this is helpful!
Help
When browsing web pages I am getting writing over writing and can’t read some of the content.
Also, some of the boxes where I need to fill out info are too small and I can’t get to all of the info to complete.
I tried resetting Safari and it didn’t help. I was told to do something with .plist but don’t understand that at all.
Melanie
Thanks alot for your post. Didnt help me personally, but so good to see thourough posts help others. I had a scenario where Fireworks CS 5 would not start up on OSX lion. It turned out that all my plist files were correct, yet the files in the ~/LIbrary/Preferences/macromedia where conflicting somehow with Fireworks CS 5. So after throwing that folder out it now works.
This is exactly the info I was looking for.
You Rock!
1onut I don’t think a plist file can be dangerous because, as you said, it’s just XML data, but I suppose you could theoretically include some code that would be executed by an XML parser when it read the file, depending on the app that was scanning the plist. I think that’d be a pretty tricky thing to pull off, though…
can a .plist file be dangerous? for example a virus/troian included with it or something similar? I think not, because it is just an xml file, but I am asking just to be sure. thanks
Hello Dave,interesting article,but please can you use laymen’s and not scientific techno babble as I am an ordinary person,and not a computer engineer or genius like yourself,step by step instructions would help,I have a problem where safari keeps quitting,deleting the plist doesn’t help,I find safari to be a useless browser to be honest,but I like the way the bookmarks works work,however opera and camino are far more reliable,but as it’s my default browser I would like to get in working properly,I current use Tiger,can you suggest anything?
Many thanks.
Karl.
DJ,
It’s been two years since you asked, but if I understand your question correctly:
| is the “pipe” symbol, located above “return” on the right of the keyboard.
As for the “application” you mention, you are talking about the Terminal itself. It can do both of those things. You can drag scripts into it to run them, and copy and paste any text between the terminal and other applications.
Dave:
I’m encountering a problem in imovie 09. When I attempt to transfer a movie to IDVD from the share menu. As the movie downloads onto IDVD it quits after 19 minutes of download,
and I receive the following error message. ” Application unexpectedly quit” The crash occurs at:
exception type: Exc_crash(sigabrt)
crashed thread 1
thread 1 crashed libsystem,b.dylib
I hope you can helo me.
Thanks
Frank Fontana
Are there any plists you can just delete on a regular basis that would be of benefit. I know deleting Adobe software plists is good practice.
I found a very long plist on my hard drive when I was trying to search why my internet (and computer) is suddenly sooo slow. I wish there were instructions for users like me who know nothing other than using the software, i.e., Excel, Word, etc., with just a basic knowledge of the rest of the computer. I’m curious about the plist also, but too uneducated to even follow along your instructions. I wish there were alternate additional instructions for me (and people like me) when I don’t know what I’m doing! I’ve learned the hard way if I can’t understand it, then don’t get into the more advanced levels, then I know just enough & risk how make things worse.
HELP! Please guys remember we need help too!
DJ,
The backquote key is the same as the tilde (~) key, just minus the operation.
OK … I haven’t worked in the terminal extensively before and while this is all intriuging … but this all seems rather daunting.
Seems like it would be pretty easy to mess things up … and once fiddled with pretty hard to recover.
To prove my cluelessness, here’s a real ‘newbie’ question … in your example above how are you actually rendering these vertical divisions between the commands?
ie:rm -i `plutil -s *.plist | grep ‘plist:’ | sed ‘s/://g’
Perhaps I’m being dense but I’m looking at my Macintosh keyboard and I don’t see any keystroke that might render that character… or is that a shorthand method to signify that the commands are entered on seperate lines?
I seem to remember seeing some application for working within the terminal wherein you might copy and paste correctly compiled scripts and even drag and drop selected text in and out of the terminal window … with an included ‘undo’ feature built-in … does anyone happen to know the name of that app?
Found you by Googling “plist”…good information. Will check back.
SOLUTION – Some plists have dumb names that trip up plutil, e.g. files starting with a dash, which it things are arguments (e.g. -BringToFront.plist), and files with spaces in ’em. I renamed ’em, ran piutil, and renamed ’em back.
There are plists in other places, in the filesystem too.
Even this probably doesn’t catch all of ’em:
plutil -s ~/Library/Preferences/*.plist ~/Library/Preferences/*/*.plist /Library/Preferences/*/*.plist
My plists had no errors. 🙂
PS. Check out the link to thank me.
Dave,
The command works in the main Library/Preferences folder, but not in the users Library/Preferences. I tried both. The user folder doesn’t like the *.plist
Dave,
I have the same problem as Bob. I get an error using “*.plist.” Oh my Man page has -s listed. I’m on Tiger 10.4.2
That’s a strange error to see, Bob. When you type in
man plutil
does it show that your version has a “-s” flag at all?
WRT the plutil program. It works on a single file but when I try ‘plutil -s *.plist’ I get the error message ‘Unrecognized option’
Any thoughts?
Dave,
Wow! Great info. Can’t wait to try it at work next week. Thanks!
Can I check my “plist” files in Mac OS X for problems?
I keep hearing that if any of my programs start to act oddly within Mac OS X that one culprit can be the preferences file for that particular program. That’s all well and good, but what if the corrupted preferences file is messing up things I can’t see…