Printer Management

Managing printers via the command line


Adding and Removing a Printer

This is done via the lpadmin command. To add a printer, use this format:

lpadmin -p Printer_Name -L "Printer Location" -E -v lpd://x.x.x.x 
 -P /Library/Printers/PPDs/Contents/Resources/en.lproj/Printer_Driver.gz
(note: the example above is all one line.)

All you have to do to the above is adjust the settings as necessary. Unfortunately, the tradeoff here is that you can't use spaces in the Printer_name, at least from what I can determine. [Edit: spaces can be accomodated using Unix syntax – Printer\ Name ]. '“Printer location”' can be any string enclosed in double quotes. An IP address belongs in the x.x.x.x bit, and change lpd: to ipp: if that's what you use. I'm unsure about other protocols, but perhaps the man page can tell you much more about this command. Last of all is the driver. Before using the command, you'd be best to look in the directory shown and find the filename, and then replicate it in the command line. If you're lazy you could always just drag the PPD file over to the Terminal window, too!

To remove a printer,

… it's a far simpler affair. Simply:

lpadmin -x Printer_Name

Queue Management

Nothing is more annoying than a printer, well, printing things, when people have walked away leaving nothing but a big pile of print jobs behind. And the last thing anyone should have to do is find and clear all printer queues manually. Thankfully, this too is easily resolved. Here are just a couple of commands I've found very helpful; I'm sure there are more if you go looking.

To find out what printers are installed

– this one is great for finding the names should you need them with the command above – simply use this:

lpstat -p

If you want to see the current jobs on a computer, simply use this command. (Note that this will show the jobs for the specified printer. However, if you do not specify a printer, it will show the jobs for all queues.)

lpstat -o Printer_Name

To clear a queue of all jobs,

we use lprm. Note in this example the first hyphen is solo. This forces all jobs to be cleared; more methods to clear individual jobs or those of a particular are explained in the man page.

lprm - -P Printer_Name

Clearing all queues

Unfortunately I could not find a command which removed all jobs from all queues. So I wrote up a small script which does this for you. You could deploy this as a shell script file and then execute it (good for both SSH and ARD), or in the case of Apple Remote Desktop's “Send UNIX Command” function, simply throw in the whole script and run it as root.


lpstat -p | awk '{print $2}' | while read printer
  echo "Clearing Queue for Printer:" $printer
  lprm - -P $printer

Last modified:: 2016/03/19 16:03