Reset Printing System on macOS

Every once in a while, a client workstation will have printing issues that are only resolved after resetting the print system through System Preferences and then re-installing the printers.

Reset Printing System in System Preferences

Although I have printer installing packages in place, I would also like to have a quick way to reset this for someone without having to connect through remote desktop and manually clicking this.

It turns out that, aside from stopping and starting cups, resetting the printing system does the following tasks.
1. Remove all printer queues
2. Set cups defaults
3. Set permissions in the drivers directories

I’ve used this script to reset it in the background without bothering the user:

#!/bin/sh

# stop cups
launchctl stop org.cups.cupsd

# remove printer list
lpstat -p | awk '{print $2}' | xargs -I{} lpadmin -x {}
rm /Library/Printers/InstalledPrinters.plist
touch /Library/Printers/InstalledPrinters.plist

# set cups files to defaults
rm /etc/cups/cupsd.conf
rm /etc/cups/cups-files.conf
cp /etc/cups/cupsd.conf.default /etc/cups/cupsd.conf
cp /etc/cups/cups-files.conf.default /etc/cups/cups-files.conf
rm /etc/cups/printers.conf

# set print driver permissions
chown -R root:wheel /Library/Printers
chmod -R 755 /Library/Printers

# start cups
launchctl start org.cups.cupsd

exit 0

After this, installer packages for printers can be pushed out.