Adding a printer using lpadmin

By | February 19, 2016

I <3 printers!

I really wanted to start this one out on a positive note, but unfortunately my editor (me) wouldn’t allow our integrity to be sacrificed by printing a lie in bold at the beginning of a post.

Our district was at the end of our current copier lease and after a temporary extension, we ended up renewing most locations with the same hardware vendor, Riso (Ree-So).

After a few conversations with their folks, we were provided with a three page document on how to set certain options and save them as a template on Mac OS X. That really wasn’t my idea of a seamless deployment method for our fleet, so I set out to dig through their driver options to see if we could find a way to deploy our desired configuration consistently.


CUPS (Common Unix Printing System) was developed by Apple to act as a built in Print Server. The tools we will be working with are used to control this back-end service and configure the available options.


The lpoptions command is what we can use to view or set printer options and defaults for the CUPS print system

We can use this to set both user and system level options. Since we want the settings to be consistent from user-to-user, we will want to run lpoptions as root or using sudo.


The first step I need to take is to manually add the printer using the standard Printers & Scanners dialog. Try to give the device a simple name (no spaces, dashes, or special characters) as it will make your job easier in the following steps.

Once added, I want to grab all of the options presented by the printer driver. This list can be quite extensive at times, so I like to dump it to a text file for easy reference and searching later one.

This command will output all the printer’s PPD options to a file on the current users desktop called PrinterOpts.txt. The command should run fairly quickly, so once you’re returned to a terminal command line, take a look at the file on your desktop.

The file continues, but you get the point. Each line is an individual option available via the print driver. Lets take a look at just a single line and break it down

Screenshot 2016-02-17 21.33.38

We will use the option name (text before the forward slash) in the command to setup our printer.

The friendly name can help can help us decipher the sometimes cryptic option name. These generally match up with what is shown in the GUI of the printer settings.

Finally, the options show the available settings we can configure. In this case we have 5 available settings. Note the asterisk (*) next to the default setting.

Using this information, we can install a printer and change those defaults with the lpadmin command:

Lpadmin Flags:

  • -p printer: This is the name you want to give your printer
  • -v device-uri: I’m adding the printer via the HP Socket via Hostname. So in this case I use “socket://HostName”. There are a few other common options:
    • “ipp://HostName” for Internet Printing Protocol
    • “lpr://HostName” for Line Printer Daemon.
    • Need more? Run lpinfo -v to show supported options for your OS.
  • -P ppd-file: Use this to specify a printer driver PPD file for the printer.
  • -L location: Enter useful location information for the printer’s location.
  • -o options: Here we can enter in any option(s) that we want to configure as default.
    • Note, these can be chained together with multiple -o flags for each option needed.

What’s the semi-colon for?

Ok, so I cheated a little bit. The line above is a small one-line script that configures, enables and allows printing for the printer we just setup. The semi-colon is treated as the end-of-command signal for the shell to run each command as its own line.

(If you want, you can replace the semi-colons with two ampersands “&&” and it will only process the following commands IF the previous one succeeds.)


Using this one-line script, I can encourage the use of our preferred settings to the end user without requiring any additional setup steps for them to get started printing. Not all applications will respect these settings, so be aware that your mileage may vary between two applications on the same machine. The user is also free to make changes to these default options but depending on what you configure, they may never go to the extra effort.

Leave a Reply

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