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

CUPS Basic Commands

20200213 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
...

List installed printers and the device URI.

$ lpstat -v

Here's an example using a socket:

$ 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 (for a printer with a corresponding PPD in /etc/cups/ppd/ can be viewed with:

$ lpoptions -p lp1 -l

Options can then be set with:

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

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 also 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


Support further development by purchasing the PDF version of the book.
Other online resources include the Data Science Desktop Survival Guide.
Books available on Amazon include Data Mining with Rattle and Essentials of Data Science.
Popular open source software includes rattle and wajig.
Hosted by Togaware, a pioneer of free and open source software since 1984.
Copyright © 1995-2020 Togaware Pty Ltd. . Creative Commons ShareAlike V4.