Linux newbies often complain -- justifiably, in my view -- of the difficulty of configuring a Linux printer. It's cold comfort to the newbie to point out the power and sophistication of Linux's printing system when nothing prints. Printing is one of those things most people would rather never have to know about. But if you've already pointed and clicked, and your printer just doesn't seem to work, this article will help you get the hard copy you need.
|Figure One: How the lpd printing system works.|
Linux newbies often complain — justifiably, in my view — of the difficulty of configuring a Linux printer. It’s cold comfort to the newbie to point out the power and sophistication of Linux’s printing system when nothing prints. Printing is one of those things most people would rather never have to know about. But if you’ve already pointed and clicked, and your printer just doesn’t seem to work, this article will help you get the hard copy you need.
The lpd Printing System
There are actually a few printing systems that work with Linux, but all of the major distributions use the lpd system. It’s the one that uses the lpr command. (You’ll see lpr in the dialog box if you try to print something from Netscape, for example.)
As shown in Figure One, the lpd printing system has six main parts:
* the command that is used to initiate printing (lpr)
* software (called a daemon) that handles print requests (lpd)
* software (a socket) that communicates with the printing system’s daemon (/dev/socket)
* a queue (the print spool queue) maintained by the printing system’s daemon process so that it can accept print requests while the printer is active. It is a set of files stored in a directory like /var/spool/lpd.
* a configuration file (/etc/printcap) that specifies printer options
* a kernel driver (parport) that provides access to the parallel port
Controlling the lpd Printing System
|Figure Two: Killing a print job with Klpq.|
|Figure Three: The GNOME printer queue.|
If you use KDE, you can control the print queue by using KDE’s printer-queue program, klpq. To use klpq, first select “KDE->Utilities> Printer Queue.” Then the klpq dialog box appears, as can be seen in Figure Two.
To manage the print queue by using klpq, highlight the print job you want to cancel and click “Remove.”
If you use GNOME, you should use its printer-queue program, gnomepq. You can find it at http: //shogun.penguinpowered.com:81/~peppe/. The program is available as source code or as an RPM file. If you’re using an RPM-based distribution, download the RPM file and install it by issuing the command:
rpm -Uvh gnomepq-0.2-
where gnomepq-0.2-1.i386.rpm is the name of the RPM file you downloaded. To launch gnomepq, open a terminal window and issue the command:
The gnomepq dialog box appears (see Figure Three). To delete a print job, right-click the job and select “Delete” from the pop-up menu.
Installing a Printer
Most Linux distributions install printer support during the installation. However, you can do this afterwards by performing a three-step process:
1. Verify printer compatibility. If your printer is not going to work with Linux, it’s best to know that now.
2. Install kernel support for printing.
3. Install, if necessary, and configure the lpd system. Most Linux distributions preinstall the lpd system, but you probably need to configure it.
Step 1: Verify Printer Compatibility In principle, Linux can support any printer that you can plug into a serial or parallel port. However, you may not get high-quality or even useful output from some printers.
Like its Unix cousins, Linux prefers to print to a PostScript printer. However, most Linux users do not own PostScript-capable printers. Many own printers that use Hewlett-Packard’s PCL (printer control language) or some other protocol for communication with the computer. Linux copes with non-PostScript printers by using special filters that translate PostScript output to a language that an attached printer understands.
Filters exist for just about every printer, the notable exception being the dreaded WinPrinter. If you’re unlucky enough to own a WinPrinter, you may not get it to work with Linux at all. The Printing HOWTO (the URLs for this and other printer resources are listed on pg. 35) can tell you whether your particular printer is supported by Linux or not.
Step 2: Install Kernel Support for Printing Since kernel release 2.1.33, kernel support for printing has been provided by the parport device driver. This device driver can be — and generally is — compiled as several loadable modules: parport.o, parport_ pc.o, and parport_ probe.o. Every major distribution includes these modules in a subdirectory of /lib/modules and dynamically loads the modules when needed.
To make sure your kernel has the necessary modules available, log in as root in the command line and issue the command
If the command displays an error message stating that it’s unable to locate the requested module, you will need to either to reinstall Linux or to replace your kernel. Ouch! Time to get help from a non-newbie.
Several recent releases of Red Hat lack proper module-configuration information for the parallel-port driver. Make sure your /etc/ conf.modules file contains the line:
alias parport_lowlevel parport_pc
Otherwise, you will get the message “no such device” when you print.
Step 3: Install and Configure the lpd System Just about every major distribution installs the lpd system as part of the base install. So, unless you’ve removed the lpd system from your computer’s hard drive, you merely need to configure it. To verify that the lpd system has been installed, issue this command:
You should see output that describes the current state of the lpd system. For example, you may see the output no entries, which tells you that no files await printing.
If the lpq command displays an error message, you will need to reinstall the lpd system. See your distribution documentation for help in identifying the proper package.
To configure the lpd system, you must revise the contents of the /etc/printcap file. Many distributions provide tools to help you do so. For example, the Red Hat distribution provides the printtool program, shown in the Making it Work: Using print tool sidebar (pg. 34).
It’s fairly simple to revise the /etc/ printcap file using a text editor. First, make a copy of the file by issuing the command:
cp /etc/printcap /etc/printcap.save
By making this backup copy of the original file (called printcap.save), you’ll be able to recover the file if you edit it badly. Some printer-configuration tools are easily confused by manual edits of the printcap file, so if your system provides such a tool, it’s best to use it rather than edit the file.
Entries in the printcap file that have a hash mark (#) at the beginning of a line are comments, which are ignored by the lpd system. The remaining lines specify the characteristics of the printer (or printers) attached to your system. Here’s an example entry:
This entry specifies a printer named lp (by convention the printer named lp is the one to which the lpr command sends output). The second line specifies the name of the spool directory where the printer daemon (lpd) will store copies of files that await printing. The directory you should specify may vary, depending on your distribution. If it’s properly set up, you can locate it by issuing the command:
Look in the output of the command for a line that resembles /var/spool/lpd/lp and use the directory name you find. Don’t try to create your own directory, because the access permissions must be properly set. If you can’t find the proper directory, consult The Linux Printing HOWTO.
Many more configuration attributes are available. A typical printer configuration will use sd and lp, as well as sh and mx. Table One summarizes the most commonly used printer configuration attributes.
There’s no getting around it: Setting up and using Linux printing can be painful for the newbie. The best approach is to use the point-and-click tools that accompany the more user-friendly Linux distributions. These tools make hard copy easy copy.
Table 1: Commonly Used Printer Configuration Attributes
| Name|| Type||Default||Description|
| ff|| str|| ‘\f’|| string to send for a form feed|
| fo|| bool|| false|| print a form feed when device is opened|
| hl|| bool|| false|| print the burst header page last|
| lp|| str|| /dev/lp|| device name to open for output|
| mx|| num|| 1000|| maximum file size (in BUFSIZ blocks), zero = unlimited|
| sb|| bool|| false|| short banner (one line only)|
| sc|| bool|| false|| suppress multiple copies|
| sd|| str|| /var/spool/lpd|| spool directory|
| sf|| bool|| false|| suppress form feeds|
| sh|| bool|| false|| suppress printing of burst page header|
Making it Work: Using printtool
If you use the Red Hat distribution, the printtool program lets you configure your printer without editing /etc/printcap. Here’s how:
Step 1 LAUNCH A TERMINAL WINDOW
Use your desktop manager to launch a terminal window. Both KDE and GNOME have icons resembling terminals, which you click to open a terminal window.
Step 2 LAUNCH PRINTTOOL
Launch printtool by issuing the command printtool
Step 3 ADD A PRINTER
Click the “Add” button. The “Add a Printer Entry” dialog box appears.
Step 4 SELECT THE PRINTER
Select the type of printer (Local Printer, Remote Unix (lpd) Queue, SMB/Windows 95/NT Printer, or NetWare Printer (NCP)). If your printer is attached to the parallel port of your computer, the printer type is Local Printer. Click “OK”. The “Edit Local Printer Entry” dialog box appears.
Step 5 SPECIFY THE PRINTER DEVICE
Specify the Printer Device, using /dev/lp0 as the name of the first parallel port (MS-DOS LPT1). If necessary, change the “Printer Names” and “Spool Directory” to reflect a printer device other than lp0.
Step 6 CLICK SELECT
Click “Select.” The “Configure Filter” dialog box appears.
Step 7 SELECT PRINTING OPTIONS
Select the Printer Type, Resolution, Paper Size, and Color Depth. Select Printing Options as desired and set the Margins. Note the Fix Stair-Stepping Text option, which your printer may require. You may not discover that this option is needed until after exiting the dialog box. Don’t fret: You can return to this screen and revise the options at any time by starting printtool, selecting your printer, and clicking “Edit.”
Step 8 EXIT THE SYSTEM
Click “OK” to exit the “Configure Filter” dialog box. Click “OK” to exit the “Edit Local Printer Entry” dialog box. Click “PrintTool->Quit” to exit printtool. Your printer is ready to use.
Bill McCarty is an associate professor of information technology at Azusa Pacific University, Azusa, CA. He can be reached at email@example.com.