Review plist Files

From SBAMUG WIKI
Jump to: navigation, search

Introduction

The command line tool plutil will parse any selected files and validate them as well formed XML. Anyway, the point here is that corrupted preference files are likely to fail this validity test.

This shell script, which parses the two most common places where preference plist files are found, returns the errors if any are found. One can then decide to trash the files or inspect them.

The file can be placed any where but by convention I'd place it in /usr/local/bin .

Procedure

  • Using your favorite text editor, create the file plist_check.sh by doing a copy and paste.
  • Change permissions on the file to allow execution.
    chmod 755 plist_check.sh 
  • Move file to a reasonable location.
    sudo mv plist_check.sh /usr/local/bin/
  • Execute as a sudo command
    sudo plist_check.sh
  • Review errors

bash Command File

#!/bin/sh
# plist_check.sh
# Check that we are being run as root
if [ $USER != "root" ]; then
  echo "Must be root---try sudo."
  exit 1
fi
find /Library/Preferences -name "*.plist" -print0 | xargs -0 /usr/bin/plutil -lint -s
find /Users -name "*.plist" -print0 | xargs -0 /usr/bin/plutil -lint -s