Add a printer via command-line in OS X

Goal: add a network printer via Remote Desktop’s command-line to numerous Macs.

The following commands have worked for me:

lpadmin -p "NAME" -v "URL" -P "PPD" -o printer-is-shared=false -E
cupsenable "NAME"
cupsaccept "NAME"

…where:

  • -E — enables the printer.
  • -o printer-is-shared=false — the added printers are shared by default (i.e. “Share this printer on the network” would be ticked). Since my printer is already shared on the network, I don’t want to share it again from the Macs.
  • NAME — arbitrary name, can be anything, e.g. “MyBadassPrinter”.
  • URL — the printer’s URL.
  • PPD — the path to a .ppd (PostScript Printer Description) file.

Probably you don’t know how to find the URL and the PPD of the printer.

The first step to retrieve them is to add the printer to your computer via System Preferences > Print & Scan.

Now let’s find the URL. What follows is probably not the best way to do it, but it’s worked for me. Run the following to enable CUPS web-interface:

cupsctl WebInterface=yes

In your web-browser open http://localhost:631/printers/, click on your printer’s name and copy the URL after “Connection”:

cups-connection

How to get the PPD? This is easier: go to /etc/cups/ppd/ and copy the PPD file. Obviously you’d want to put it on a local NAS or in some other place that would be accessible by other Macs.

The final command for me was:

lpadmin -p "AFFA-ST-MFP-1" -v "dnssd://AFFA-ST-MFP-1._ipp._tcp.local." -P "/Volumes/Servers/AFFA_ST_MFP_1.ppd" -o printer-is-shared=false; cupsenable "AFFA-ST-MFP-1" -E; cupsaccept "AFFA-ST-MFP-1";

Further reading:

This entry was posted in How to’s and tagged , . Bookmark the permalink.

6 Responses to Add a printer via command-line in OS X

  1. S says:

    Thanks for this guide – very helpful. Might be worth changing all the “PDD” references to “PPD” for clarity though :)

  2. Martin says:

    This looks good, can the PPD file part be omitted?

  3. John says:

    Our printers do not need PPD. Is it possible to add IPP printer without PPD?

  4. sr9 says:

    from lpadmin(8):

    When specified before the -d, -p, or -x options, the -E option forces encryption when connecting to the server.

Leave a Reply

Your email address will not be published. Required fields are marked *