-->
Page 229
Page 230
This chapter shows you how to use your printer with Linux. A number of programs, files, and directories are integral to supporting printing under Linux, but you'll find that with little effort, you'll be able to get to work and print nicely formatted documents or graphics.
If you can print to your printer from DOS, Windows 95, or Windows NT, don't worry! You'll be able to print under Linux, and will probably be pleasantly surprised by the additional printing capabilities you won't find in the commercial operating system installed on your PC.
As a Red Hat Linux user, you'll be especially pleased because the kind folks in North Carolina have hidden the ugly and gory details of installing and using a printer, and have made the process a snap!
Under Linux, each piece of your computer's hardware is abstracted to a device file (hopefully with an accompanying device driver in the kernel; see Chapter 11, "Filesystems, Disks, and Other Devices," for more details). Printer devices, traditionally named after line printers, are character mode devices, and will be found under the /dev directory. Some of these are shown in Table 12.1.
Table 12.1. Parallel printer devices.
Device Name | Printer | Address |
First parallel printer | 0x3bc | |
Second parallel printer | 0x378 | |
Third parallel printer | 0x278 |
Serial printers are assigned to serial devices such as /dev/ttySX, where X is a number from 0 to 3. There are quite a few tty devices listed in /dev. Generally, if you're going to use a serial printer, you'll have to use the setserial command to make sure the printer's serial port is set to the fastest baud rate your printer supports.
There are some special cases, such as using an old Apple LaserWriter as a serial printer (it has a Diablo print-wheel emulation mode using the Courier font), when you must define your own printer or edit an entry in the /etc/printcap database. Sometimes you can manipulate the printer to get a higher speed. For example, here's a 10-year-old trick to increase the serial port speed of the Apple LaserWriter Plus to 19200, by Dale Carstensen, and posted to the comp.laser-printers newsgroup:
%! 0000 % Server Password statusdict begin 25 sccbatch 0 ne exch 19200 ne or { serverdict begin exitserver} {pop end stop} ifelse statusdict begin
Page 231
25 19200 0 setsccbatch end % note--next line has an actual CTRL-D
See Appendix D in the RedBook, Adobe's PostScript language reference manual, for more information about LaserWriters, or peruse comp.laser-printers for hints on setting up your laser printer. Also check the /usr/lib/ghostscript/doc directory for information about 25 different PostScript printer utilities included in the Ghostscript distribution.
Most users, however, have a printer attached to the parallel printer port, so I'll concentrate on /dev/lp.
First, check to see that your printer is plugged in, turned on, and attached to your computer's parallel port. Pass-through parallel port cables shouldn't pose a problem, but don't expect to be able to use your printer while you're using your CD-ROM, QuickCam, SCSI adapter, or tape, ZIP, or SyQuest drive if attached to a pass-through cable.
For starters, try a simple
# ls >/dev/lp1
Chances are your printer will activate and its print head will move, but when you look at the printout, you might see a staircase effect, with each word on a separate line, moving across the page. Don't worry! This is normal, and tells you that you can at least access your printer. Later in this chapter, you'll find out how to fine-tune your printing.
If you're unable to print, then try using
# cat /proc/devices
to see if the lp device driver loaded or compiled into your kernel. You should see something like the following:
Character devices: 1 mem 2 pty 3 ttyp 4 ttyp 5 cua 6 lp 7 vcs 10 misc 14 sound 63 pcmcia Block devices: 1 ramdisk 2 fd 3 ide0 9 md 22 ide1
Page 232
You can also try the tunelp command, which sets various parameters to "tune" your
printer port or lets you know if your printer device is using interrupts or polling for printing. Try
using
# tunelp /dev/lp1
and you might see something like the following:
/dev/lp1 using polling
Or you can try
# tunelp /dev/lp1 -s
and you might see
/dev/lp1 status is 223, on-line
If tunelp reports "No such device or address," or if you do not find an lp character device, see Chapter 5, "Configuring and Building Kernels."
If you want to install, modify, or delete a local, remote, or LAN printer, you're going to love the printtool program. Found in /usr/bin, printtool is a graphical interface printer setup program you can call up from the command line or through the Red Hat control-panel program.
The control-panel and printtool programs run under X, so you'll have to first fire up X and then type
# printtool
from a terminal window. The main printtool dialog will then come up (see Figure 12.1). First, click the Add button. You'll be asked to select a local, remote, or LAN manager printer.
To set up a remote printer, you'll need the following, according to the printtool program's help information: