<< Prev  |  TOC  |  Front Page  |  Talkback  |  FAQ  |  Next >>
LINUX GAZETTE
...making Linux just a little more fun!
The CUPS printing system
By Alan Ward

The CUPS printing system is what its name says: a Common Unix Printing System. It is aimed at providing a common printing interface across a local network, masking differences between the printing system on each computer. While I am not sure that such a system is really needed in a purely Linux environment where the standard Berkely LPD provides this functionality, CUPS does provide interactivity with SMB and Windows printers. CUPS also allows dynamic printer detection and grouping.

CUPS is licenced under GPL by a company called Easy Software Products. Besides providing CUPS itself as free software, it also provides commercial addons and support.

You can get it from www.cups.org, or as a RPM package for most distributions (seen it for Mandrake, RedHat and SuSE).

How does it work?

CUPS can be seen as a replacement of the LPD printing system. It replaces the lpr command with its own, and the LPD printer drivers with its own versions. However, it is very similar to LPD in that it is based on PostScript as its underlying language for page description. Linux (and Unix) programs won't know the difference between CUPS and LPD.

It contains a list of printer drivers that include most printers with parallel port, USB and even serial connections. Note serial - connecting a printer with a null-modem serial line is slow and more difficult to set up than a parallel line, but it is sufficient for a matrix printer -- for bulk printing or multiple copies -- and makes an easy way to build a print server from a pile of older hardware. A hint to schools!

Dynamic printer detection

CUPS has a characteristic of Windows systems that is not very common in the Unix world: it broadcasts the printers available on the local computer to all other computers on the network. In this way, every computer on the local IP segment gets to know in real time which printers are available and what their status is.

Naturally, this is -- unlike Windows :-) -- configurable. You can tell CUPS (in the cupsd.conf configuration file) if and where to broadcast to, and specify how often the information is refreshed.

Grouping printers

A printer group -- called a class by CUPS -- is a group of printers that appears as a single printer to user programs. For example, you could create a group called ColorPrinters, including all your color printers. The user could then tell his program to print on printer ColorPrinters, and the output would be on one of these printers. Which one would depend on user rights or which printer is currently available.

The fact that a printer is a member of a group does not mean, in itself, that users cannot use that printer directly. However at CUPS access control level, you can make the printers reject jobs - while groups accept them. The end result is that users can use printer groups, not printers. It depends a bit on the policy on printer use you intend to implement.

Example 1

I have a workshop with five computers under Linux, all running CUPS. When changing a printer on one of them, I:

through the CUPS web interface in under 30 secs. That is all the configuration required - the other computers get their default printing routes updated in another 30 secs. Under 1 minute for the whole change: less time than a laser printer takes to warm up.

Example 2

I like to provide, in my school network:

Most of these printers hang off Windows boxes and would be directly available for other computers under Windows. However, by providing them through CUPS on a central bridge/router, I:

Integrating with Windows

To use a Windows printer under Linux or the other way round, you will need to have a Samba server working. Set this up and test it before going on (as a normal user, try viewing your home directory on the Linux computer from a Windows box). Remember to turn password encyptation on in /etc/samba/smb.conf if you are using Windows 98 or a more recent version.

CUPS can use printers shared from computers under Windows, and network printers using the SMB protocol. You configure a "Windows printer using Samba". Basically, all you have to tell CUPS is the address of the printer, as in: smb://server/printer.

Windows can use a CUPS printer shared by Samba. Proceed in the normal way to share your printers with Samba: i.e. do not do anything. Your printers are generally shared by defect. If this is not the case, edit smb.conf to create the necessary share. All the Samba share options are appliable. This is because Samba treats a CUPS printer in the same way as a LPD printer.

Network printers

Network printers -- i.e. a printer with a network interface, that doesn't need a host computer to be made available to the network -- can use any of a variety of protocols:

In the first two cases, proceed as with a printer hosted by a computer. In the third, you are probably at a dead end. This happened to me with a Lexmark: I ended up sharing it from a Windows box.

Configuration

There are two ways of configurating CUPS. One is editing the configuration file /etc/cups/cupsd.conf. The other is a classical web-based interface you can access at port 631. This is very similar to the web-based configuration of many network-capable printers, and should be intuitive for all.

Generally, you can access the web interface only from the localhost interface, not from other computers. However, you can change this by changing the following lines in the configuration file cupsd.conf, and restarting CUPS:

<Location />                   # this location is the main screen
Order Deny, Allow
Deny From All
Allow From 127.0.0.1           # allow configuration from local host
Allow From 192.168.1.*         # allow configuration from any machine
                               # on the 192.168.1.0/24 subnet
Allow From mybox.mydomain      # this is my desktop on another segment
</Location>

You can also specify one by one which menu items (called Locations in CUPS terms) are accessible from any particular IP address. This doesn't mean that other computers will not be able to connect to the server - just that they won't be able to access contents.

If your Linux box is acting both as a print server and a bridge between two or more IP segments, you can also specify on which network interfaces it will listen for requests:

Listen 127.0.0.1:631		# Should already be there
Listen servename:631		# Add your server name here
Listen 192.168.1.1:631		# You can also use your IP address

In the above example, the web interface will be visible through my eth0 interface with IP address 192.168.1.1, but not through the eth1 interface with IP address 172.16.0.1 .

Though user identification is required through basic login/password authentication, note that you can use SSL to connect to the web interface through the https secure protocol. This is also relatively easy to configure in the cupsd.conf file.

The web interface has a comprehensive help system with plenty of documentation about what CUPS is and how to configure it.

PS. Should anybody want to translate this article: I wrote it in the spirit of the GPL software licence. i.e. you are free (and indeed encouraged) to copy, post and translate it -- but please, PLEASE, send me notice by email! I like to keep track of translations -- it's good for the curriculum :-)

 

[BIO] Alan teaches CS in Andorra at high-school and university levels. His hobbies include science photography (both digital and traditional), trekking, rock and processor collecting.


Copyright © 2003, Alan Ward. Copying license http://www.linuxgazette.com/copying.html
Published in Issue 90 of Linux Gazette, May 2003

<< Prev  |  TOC  |  Front Page  |  Talkback  |  FAQ  |  Next >>