Basic CUPS commands
CUPS (Common Unix Printing System) currently supports two types of printer connections:
- Driver-based connection: Requires specific printer drivers to be installed
- 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:
lpinfo -vThis 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:
lpadmin -p rpi-printer -v ipp://<ipp-location-you-got-from-lpinfo> -m everywhere -EThis 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:
lpadmin -p rpi-printer -v usb://ZEBRA_ZPL_2_0/usb://<usb-location-you-got-from-lpinfo> -m drv:///sample.drv/zebra.ppd -ECommon CUPS Commands:
Remove a printer:
lpadmin -x rpi-printerCheck printer status:
lpstat -vPrint a file:
lp file-path -d rpi-printerCheck job status:
lpstat -W completed | non-completedCancel a specific print job:
cancel <job-id>Cancel all print jobs:
cancel -aSet printer options (e.g., paper size):
lpoptions -p rpi-printer -o media=A4If 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:
ipptool -tv ipp://localhost:60000/ipp/print get-printer-attributes.testHow to connect to an IPP printer:
lpadmin -p rpi-printer -v ipp://localhost:60000/ipp/print -m everywhere -E