Skip to content

Basic CUPS commands

CUPS (Common Unix Printing System) currently supports two types of printer connections:

  1. Driver-based connection: Requires specific printer drivers to be installed
  2. Driverless (IPP) connection: Uses the Internet Printing Protocol and does not require additional drivers

As the name suggests, driverless connections do not require any printer-specific drivers to be installed on the system. For driver-based connections, you’ll need to install the appropriate printer drivers first.

After connecting a printer to your Raspberry Pi (or other computer), you can use the following command to list available devices:

Terminal window
lpinfo -v

This command will display all ports that CUPS is listening on and any detected printer devices.

You’ll typically see two types of connections:

  • Connections starting with usb:// for USB-connected printers
  • Connections starting with ipp:// for network/IPP printers

For IPP printers, you can easily connect using:

Terminal window
lpadmin -p rpi-printer -v ipp://<ipp-location-you-got-from-lpinfo> -m everywhere -E

This command adds the printer to CUPS and enables it for printing. Note that the printer name must be “rpi-printer” for compatibility with our printer binaries.

For USB printers, the process requires an additional step. You’ll need to locate the appropriate PPD (PostScript Printer Description) file for your printer model before connecting. This may require some research to find the correct PPD file for your specific printer model.

For example, to connect a Zebra ZPL printer:

Terminal window
lpadmin -p rpi-printer -v usb://ZEBRA_ZPL_2_0/usb://<usb-location-you-got-from-lpinfo> -m drv:///sample.drv/zebra.ppd -E

Common CUPS Commands:

Remove a printer:

Terminal window
lpadmin -x rpi-printer

Check printer status:

Terminal window
lpstat -v

Print a file:

Terminal window
lp file-path -d rpi-printer

Check job status:

Terminal window
lpstat -W completed | non-completed

Cancel a specific print job:

Terminal window
cancel <job-id>

Cancel all print jobs:

Terminal window
cancel -a

Set printer options (e.g., paper size):

Terminal window
lpoptions -p rpi-printer -o media=A4

If an IPP printer is connected via USB, the ipp-usb package will convert that USB connection to an IPP connection. Usually, ipp-usb runs on port 60000, so your connected printer will be available on that port.

How to check if a printer is available at that location:

Terminal window
ipptool -tv ipp://localhost:60000/ipp/print get-printer-attributes.test

How to connect to an IPP printer:

Terminal window
lpadmin -p rpi-printer -v ipp://localhost:60000/ipp/print -m everywhere -E