Printing with CUPS, Part 2

By Carla Schroder | Jul 16, 2003 | Print this Page
http://www.enterprisenetworkingplanet.com/netos/article.php/2236011/Printing-with-CUPS-Part-2.htm

Each variant of Unix has its own printing system with its own unique behaviors and shortcomings. CUPS, the Common Unix Printing System, is a free single-solution tool for Unix and Linux that standardizes printing in these environments. In this second article of my two-part series focusing on CUPS, we'll explore using CUPS with networked printers, including network-direct, and Windows servers and clients.

CUPS Printer Server

The online CUPS Software Administrator's manual, excellent as it is, is not completely up-to-date on connecting client machines. My manual claims that CUPS automatically broadcasts itself on its own subnet, and becomes automagically available to clients. While older editions of CUPS did indeed do this, the latest editions do not accept connections from client machines by default; rather, this option must first be enabled. (I am using CUPS 1.1.15; if the manuals have been corrected in more recent versions, hurrah!)

First, the print server needs a static IP, and then some edits must be made to cupsd.conf. In cupsd.conf, find:

<Location />
Order Deny,Allow
Deny From All
Allow From 127.0.0.1
</Location>

Add the local network information using values appropriate for your network:

Allow from 192.168.1

Then find the BrowseAddress section and specify the broadcast address:

BrowseAddress 192.168.1.255

Restart CUPS. The default browse interval is 30 seconds, so within short order, Linux client machines will display all installed printers in their CUPS web interfaces (or you can get the information using the lpstat -t command). The browse interval is configurable.

Classes

Printers are organized into classes; by default, they are all lumped into a single class. Print jobs sent to a class will go to the first available printer. Classes can even contain their own classes, which are useful for organizing distributed high-volume printing. CUPS creates implicit classes when more than one server points to a particular printer, which ensures that the print jobs still get through if one server goes down.

Quotas

CUPS supports printer-based quotas. They cannot be configured per user, though; for example, a daily quota of 10 pages on the expensive color plotter will apply to all users. However, each user will be logged individually. Quotas can be either numbers of pages or kilobytes.

# lpadmin -p expensive_plotter -o job-quota-period=604800 -o job-page-limit=10
# lpadmin -p expensive_plotter -o job-quota-period=604800 -o job-k-limit=1048576

Logging

Logs are kept in /var/log/cups. They are automatically rotated. Everything is logged — individual print jobs with time, date, and user; errors; and each page, with the printer it was sent to.

Network-Direct Printers

Printers that connect directly to a hub or switch, such as HP Jet Direct printers, are added by selecting AppSocket/HP JetDirect in the CUPS 'Add Printer' menu. These normally connect on port 9100, so the deviceURI looks like socket://[hostname or IP]:9100.

Page 2: Windows Clients

Windows Clients

Windows 98, ME, 2000, and XP clients will happily print directly to a CUPS printer, via IPP. IPP may need to be installed on 98 and ME (see Resources for additional information). Once you've ensured IPP is installed, simply fire up the Add Printer wizard, select Network Printer, and then add the printer URL. This consists of the IP address or server name, port number, and printer name. Be sure to use the exact name you gave the printer, like this:

http://192.168.1.2:631/printers/hplaserjet

In Windows 2000/XP, this should be sufficient for adding a network printer, but if it does not connect, try these steps:

  • Add a printer port, using the exact printer URL as the port designation
  • Add TCP/IP Print Services (Network and Dial-up Connections-> Advanced Menu -> Optional Networking Components -> Other Network File and Print Services)
  • It never hurts to reboot and then try the connection again
When Windows connects to the CUPS server, it will install its own local printer drivers. It will also print its own test page, rather than the CUPS test page.

CUPS can also connect to a Windows 2000 print server. Here's how to enable this:

  • Enable TCP/IP Print Services on the Windows 2000 machine: Administrative Tools ->Services -> TCP/IP Print Server -> Startup Type Automatic
  • Set up sharing and permissions on the printer
  • Add the printer to CUPS, selecting LPD/LPR Host. The deviceURI is lpd://[IP or server name]/[shared printer name]
  • Select the driver, and away you go
CUPS also supports printers set up as Samba shares — look at the very end of the 'Device' menu in the CUPS 'Add printer' menu.

Linux Clients

Make it easy on yourself — use CUPS on all of your Linux/Unix clients. Each CUPS installation contains the server and the client, giving complete functionality to the clients.

Most printing is done from within applications. Linux applications vary wildly in their levels of printing support. This is mainly due to the fragmented Unix heritage of having several different printing subsystems, which were difficult for application developers to support. CUPS aims to provide a standard printing platform for all flavors of Unix and Unix-type operating systems. CUPS also adds printing options that may not otherwise be available when printing from inside an application.

For example, this article was written in Abiword, which has only a basic printing menu. Fortunately, it provides for additional commands on the "printer command" line in the print dialogue box. This command specifies the printer, and prints odd pages only:

lpr -P epson600 -o page-set=odd

Here's a fun one that prints multiple pages on a single page, shrunk to fit. I use this for proofreading to save paper. (Of course, I'm sure my aging eyeballs will someday make this a non-option for me.) Available quantities are 1, 2, 4, 6, 9, and 16:

lpr -o number-up=4

Command-Line Printing

As you can see, CUPS supports the familiar old System V (lp) and Berkeley (lpr) commands. Any file format supported directly by CUPS, such as text, PostScript, PDF, HP-GL/2, and most image files, can be printed directly from the command line:

$ lpr fake_document.pdf

Unsupported file formats, such as .abw, need to be printed from inside the applications that created them. CUPS will obligingly print them directly, but the output will consist of gibberish.

$ lpadmin -d [printer_name] sets the default printer, when more than one is available
$ lpstat -p -d displays the available printers
$ lp -d [printer_name] [filename] selects the printer
$ lpstat -o -p displays current jobs and job IDs
$ cancel [job-id] cancels print jobs

There are zillions more command-line print options; please see the CUPS Software User's Manual for additional options.

Conclusion

CUPS is a rich, full-featured printing system, good for small standalone systems or for supporting large operations. Printing on any platform is a large, complex subject. Please see the documentation and mail lists specific to your Linux distribution for help. Listed below are more comprehensive sources of help and information. The KDEPrint site is especially helpful for understanding the underlying protocols and concepts.

Resources

Easy Software Products
Linuxprinting.org
HP Glossary of Printing Terms
KDEPrint
Windows ME and IPP
Gimp-Print for OS X

» See All Articles by Columnist Carla Schroder