Go to TogaWare.com Home Page. GNU/Linux Desktop Survival Guide
by Graham Williams
Duck Duck Go



CLICK HERE TO VISIT THE UPDATED SURVIVAL GUIDE

CUPS Command Basics

20190812 CUPS provides a convenient command line to administer printers. We can identify available printers with:

$ lpinfo -v
...
network dnssd://Brother%20HL-3040CN%20series._pdl-datastream._tcp.local/
network socket://192.168.178.26:9100
network lpd://BRN001BA9236DC1/BINARY_P1
...

Here's an example using the socket protocal:

$ lpadmin -p lp1 -v socket://192.168.178.26:9100/ -E

Another example for a LPD (Line Printer Daemon) print server:

$ lpadmin -p lp2 -v lpd://printhost/lp1nd -E

To add information about the Location and a Description of the printer:

$ lpadmin -p lp3 -L "Level 2 South" -D "HP LaserJet 4"

To specify a PPD for the printer:

$ lpadmin -p lp4 -P usr/share/ppd/Brother/brother_hl3040cn_printer_en.ppd
$ lpadmin -p lp5 -P LEXC750.PPD

The PPD file is copied into /etc/cups/ppd/lp5.ppd, for example.

Printer options (assuming it has a PPD) can be viewed with:

$ lpoptions -p lp1 -l

Options can be set with:

$ lpoptions -p lp7 -o PageSize=A4
$ lpoptions -p lp1 -o PageSize=A4

And so on. These options are placed in /etc/cups/lpoptions. The same options can be set using the web interface. The web interface is indeed somewhat easier to use, and it modifies the PPD file directly (e.g., /etc/cups/ppd/lp1.ppd) rather than using the /etc/cups/lpoptions file!

Printer options can be accessed directly from the command line when printing, if the printer's PPD supports the option. For example, the HP LaserJet 4050 driver (from hp-ppd) supports n-up printing and watermarks:

  $ lp -o HPNup=TwoUpL sample.pdf
  $ lp -o HPwmText=Draft odbcmine.pdf


Copyright © Togaware Pty Ltd
Support further development through the purchase of the PDF version of the book.
Brought to you by Togaware and the author of open source software including Rattle and wajig.
Also the author of Data Mining with Rattle and Essentials of Data Science.