Chapter 7. Adding a printer to CUPS by using the lpadmin utility
Chapter 7. Adding a printer to CUPS by using the lpadmin utility Before users can print through CUPS, you must add printers. You can use both network printers and printers that are directly attached to the CUPS host, for example over USB. You can add printers by using the CUPS driverless feature or by using a PostScript Printer Description (PPD) file. Note CUPS prefers driverless printing, and using drivers is deprecated. Red Hat Enterprise Linux (RHEL) does not provide the name service switch multicast DNS plug-in ( nss-mdns ), which resolves requests by querying an mDNS responder. Consequently, automatic discovery and installation for local driverless printers by using mDNS is not available in RHEL. To work around this problem, install single printers manually or use cups-browsed to automatically install a high amount of print queues that are available on a remote print server. Prerequisites CUPS is configured . The printer supports driverless printing , if you want to use this feature. The printer accepts data on port 631 (IPP), 9100 (socket), or 515 (LPD). The port depends on the method you use to connect to the printer. Procedure Add the printer to CUPS: To add a printer with driverless support, enter: If the -m everywhere option does not work for your printer, try -m driverless: <uri> , for example: -m driverless: ipp://192.0.2.200/ipp/print . To add a queue from a remote print server with driverless support, enter: If the -m everywhere option does not work for your printer, try -m driverless: <uri> , for example: -m driverless: ipp://192.0.2.200/printers/example-queue . To add a printer with a driver in file, enter: To add a queue from a remote print server with a driver in a file, enter: To add a printer with a driver in the local driver database: List the drivers in the database: Add the printer with the URI to the driver in the database: These commands uses the following options: -p <printer_name> : Sets the name of the printer in CUPS. -E : Enables the printer and CUPS accepts jobs for it. Note that you must specify this option after -p . See the option's description in the man page for further details. -v <uri> : Sets the URI to the printer or remote print server queue. -m <driver_uri> : Sets the PPD file based on the provided driver URI obtained from the local driver database. -P <PPD_file> : Sets the path to the PPD file. Verification Display the available printers: Print a test page:
lpadmin -p Demo-printer -E -v ipp://192.0.2.200/ipp/print -m everywhere lpadmin -p Demo-printer -E -v ipp://192.0.2.201/printers/example-queue -m everywhere lpadmin -p Demo-printer -E -v socket://192.0.2.200/ -P /root/example.ppd lpadmin -p Demo-printer -E -v ipp://192.0.2.201/printers/example-queue -P /root/example.ppd lpinfo -m drv:///sample.drv/generpcl.ppd Generic PCL Laser Printer lpadmin -p Demo-printer -E -v socket://192.0.2.200/ -m drv:///sample.drv/generpcl.ppd lpstat -p printer Demo-printer is idle. enabled since Fri 23 Jun 2023 09:36:40 AM CEST lp -d Demo-printer /usr/share/cups/data/default-testpage.pdf