-->
Previous Table of Contents Next


Printer Drivers

Every printer on the Linux system must have a printer driver. The printer driver essentially tells Linux how to send instructions to that printer. It’ll have things like “to eject a page, do this” and “to change color to red, do this” as a series of instruction codes.

Linux has a series of printer drivers included with it, and more are available from Web and FTP sites. You need to find a printer driver intended for your printer or one of the printers that it is compatible with. If you use a noncompatible printer driver, then you may get all kinds of strange behavior from your printer!

Linux reads all the information about a printer and how to talk to it from a file called /etc/printcap. The /etc/printcap file is quite large and is usually set so that only root can modify it. Each entry in the /etc/printcap file describes how to do different things to your printer. Some Linux systems prevent any kind of access to the /etc/printcap file and insist you use a tool to modify it. For example, Figure 20.1 shows the output from a RedHat 5.0 system when you try to use more to display the contents of the /etc/printcap file. In this case, RedHat wants you to use the X-based print tool to modify the /etc/printcap file. Not all versions of Linux are this careful and let you modify (and screw up) the file to your heart’s content.


Figure 20.1.  Some systems don’t let you browse the /etc/printcap file.

You could edit the /etc/printcap file with all your printer’s codes (which is how we used to do it in the old days) but that’s slow, awkward, and prone to errors. Instead, it’s better to look for a compatible driver for your printer and let that take care of the problems for you.

Apart from the driver that tells Linux how to talk to your printer, there are other devices that may be involved every time you print something. This typically occurs when your printer uses a page descriptor language (PDL) such as PCL or PostScript. When a PDL is involved in printing, your application or the shell sends your data to be printed to the PDL first, which acts like a filter to convert the data to the proper format for printing. This formatted data is then sent to the printer using the printer driver.

If you have a printer that can handle many different PDLs, you could potentially have more than one filter involved. Each filter system is set up separately for a printer. For example, if you have a Hewlett-Packard LaserJet that handles both PCL and PostScript, you may have one printer defined that use the PCL filter, then the LaserJet device driver, and another printer defined that uses the PostScript filter and then the same LaserJet device driver. Both printers use the same device driver and port, which is fine for Linux. It lets you define as many printers as you want, in any combination of ports and filters. When you send something to the printer, your command tells Linux which printer definition (filter, device driver and port) to use. Some printers, notably older dot matrix and daisywheel printers, do not need filters, and these accept data straight from the application to the device driver.

Linux Print Commands

Because Linux is based on UNIX, several print commands and utilities may be used on your version. The most common print commands are lpr, lpd, and lpc. These three print utilities are all slightly different, and configuring them to work properly can often be more troublesome than configuring the rest of the Linux system!

When you print a file (from Emacs or a word processor, for example), the print utilities are invoked. They copy the data to be printed to a spool directory and store the contents in a file. This is done for two reasons: It frees up your application right away so you can continue working (you don’t have to wait for the printing to finish before you can go on), and it allows the Linux utilities to manage print requests by priority, types of printers, forms required, and other properties. The spool directory is usually /usr/spool/lp or /var/spool/lp, although some Linux versions use other directory paths. Typically there is a separate subdirectory for each printer defined on the system, such as /usr/spool/lp/laserjet and /usr/spool/lp/bubblejet, for a system with two printers defined.


Previous Table of Contents Next