...making Linux just a little more fun!

<-- prev | next -->

A Brief Introduction to Network Printing with CUPS

By Edgar Howell

Tired of hassles with printers not intended for Linux and the endless compromises they involve, I finally decided to buy a color laser printer with a network card. There were several factors involved in making this decision:

But the consequences of this decision were not trivial. SuSE (at current writing at 9.3, I'm at 9.2) has been installing CUPS behind the scenes for several releases. Since the printer commands are pretty much the same as those used under lprng, there never was any real need to learn much about CUPS. Well, not until the network printer arrived and then very quickly the fun began.

Just one example of the problems: although the documentation says that the password wanted when logging in to admin is the root password, that has never worked for me.

However, as usual, if you know what needs to be done, CUPS really isn't that difficult to work with. Assuming that CUPS has already been installed on the machine in question, here is my list of the steps to install a network printer on it under CUPS. You will need to do this on every machine that is to have access to this printer. Note that in the following, the installation instructions of the manufacturer are irrelevant.

Make sure you select a printer for which the manufacturer provides a PPD (Postscript Printer Definition) since only the manufacturer can produce the PPD needed to make optimum use of the hardware. Actually, this is important whether the printer attaches directly to a PC or via the LAN. The printer I selected didn't have a PPD on the CD-ROMs that came with it, but a little time searching the Internet pointed me at a file that had two - one for the black and white variety, and one for color.

As root, do the following:
  1. In /etc/cups/cupsd.conf comment out AuthType, AuthClass and AuthGroupName
  2. Add "cupsd : ALL" to /etc/hosts.allow
  3. Copy the PPD for the printer into /usr/share/cups/model/
  4. Restart CUPS with "/etc/init.d/cups restart"
  5. As some (non-root) user, issue the following command (almost verbatim from the CUPS documentation):
    	/usr/sbin/lpadmin -p net_printer -E -m printer.ppd \
    		-v socket://192.168.0.1
    
    • "net_printer" is the name to be assigned to the printer and can be any text string. If there is only one printer, the name won't need to be used in any print commands.
    • "printer.ppd" is the name of the PPD file you placed in /usr/share/cups/model/.
    • The IP-address I had previously assigned through the front panel on the printer but CUPS includes a command, arp, with which to do this by using the Ethernet MAC address.
  6. Then check on the status of printers: "lpstat -p -d". The output should look something like:
    	printer net_printer is idle.  enabled since Jan 01 00:00
    	system default destination: net_printer
    
The line "system default destination" is important. That is where Mozilla, Opera, OpenOffice, and all their friends will be printing if not told otherwise when you ask them to print something. CUPS' web interface "https://localhost:631/admin" is a convenient way to change the default printer.

Recent converts to Linux should note that a PPD is analogous to but quite different from the notorious driver. As with a driver, under CUPS one needs a PPD for the printer. But it isn't executable code that can make your system unstable. Perhaps better compared with a configuration file, essentially it just contains plain-text data that informs the print system (CUPS) what capabilities the printer has and how to format data accordingly.

On the other hand, each machine that is to send print jobs to the printer has to have the correct PPD, as is the case with a driver: the machine initiating printing has to send something to the printer that it can understand.

By following the above steps, it took me less than 15 minutes to enable a notebook under SuSE 8.0 to print via the network printer. And that includes the time it took to remove lprng and install CUPS from the distribution CD!

Keep in mind that this ignores about 99.99% of CUPS and is totally insecure. Anyone with access to your network could start print jobs wasting toner until the paper runs out.

But for a simple home system behind a firewall, it will enable your network printer under CUPS and buy you the time to learn all the things we've ignored for the moment.

 


[BIO] Edgar is a consultant in the Cologne/Bonn area in Germany. His day job involves helping a customer with payroll, maintaining ancient IBM Assembler programs, some occasional COBOL, and otherwise using QMF, PL/1 and DB/2 under MVS.

(Note: mail that does not contain "linuxgazette" in the subject will be rejected.)

Copyright © 2005, Edgar Howell. Released under the Open Publication license unless otherwise noted in the body of the article. Linux Gazette is not produced, sponsored, or endorsed by its prior host, SSC, Inc.

Published in Issue 117 of Linux Gazette, August 2005

<-- prev | next -->
Tux