-->
Previous Table of Contents Next


Chapter 20
Printing

by Tim Parker

In This Chapter
•   Setting up a printer
•   Linux print commands

In previous chapters you’ve seen a little about printing, and we’ll be covering the subject from the system administrator’s point of view in a later chapter. However, it is worth taking some time to look at how you can print files under Linux, what devices are available to you, how to set up printers, and some of the eccentricities of the Linux printing system.

It’s worth remembering that many of the printing routines used in Linux are inherited from 30 years of UNIX. In the early days, a printer on every desktop was unheard of. In most cases, a single printer or printer pool was used for everyone on a large network. UNIX’s printing routines were written with this model in mind, and although it has been upgraded and adapted to our systems today, many anachronisms are still found in the print routines.

Setting Up a Printer

In most cases Linux’s installation routine will have asked you if you wanted to set up a printer when you installed the operating system. At that point you usually had a list of printer models to choose from, and Linux asked for the port your printer is attached to. If you chose to configure a printer at that point, it should be working properly. If you skipped that installation option or didn’t get to choose it (some versions of Linux don’t bother asking), you must configure the printer manually.

There are two pieces of information you need to have before configuring a printer. The first is to know the type of printer you are using (the full name, as well as any compatible models, if possible). The reason you need to know compatible model names is simple: Linux knows about very few printers. If you just bought a brand new state-of-the-art printer that came with Windows drivers, that’s great for Windows. Linux can’t use those drivers, and you can bet that the printer manufacturer didn’t bother including a CD with Linux drivers on it! Fortunately, most printers you buy today are compatible with an older model that Linux does know about. For example, the newest Hewlett-Packard laserjet series does not have Linux drivers, but all the newest models are backward compatible with older laserjet models, and so work with the older Linux drivers. You may not get all the features of the new printer, but at least you can use the device!

The other piece of information you need to configure your printer is the port it is on. Printers tend to be available in three different connection types: parallel port, serial port, and network port. You know the parallel and serial ports from your Windows and DOS world, but network ports tend to be used only on larger systems. Parallel ports are the easiest because the communications parameters for parallel ports are unchanging. You only need to know whether you are using the first or second parallel port on your PC (most PCs only have a single parallel port: LPT1).

Serial port printers are common and require an RS-232 cable. You need to know not only the port number (COM1, COM2, and so on), but also the speed at which the printer communicates and how many bits it uses. You’ll often see things like 9600 baud, 8 bits. You must configure the printer and the serial port to run at the same speed, or you’ll get garbage, or worse, nothing, from your printer.

Network ports are actually easier to configure than serial ports. Each printer on the network has an IP address, and all you need to tell Linux is where the printer is and what kind of driver to use.

Port Names

Linux uses different names for its devices than DOS and Windows. We’ll be looking at the device names and how they are used in more detail in Chapter 33, “Devices,” so we’ll keep it simple here. A DOS LPT1 port is called /dev/lp0 in Linux, and LPT2 is called /dev/lp1. The /dev part of the name indicates to the system where to get information about that device, and the lp0 and lp1 indicate that these devices are parallel ports. Linux numbers everything starting with 0, so the second port is lp1.

The same applies for serial ports. A DOS COM1 port is know to Linux as /dev/ttyS0, COM2 is /dev/ttyS1, COM3 is /dev/ttyS2, and COM4 is /dev/ttyS3. Linux allows many serial ports, and the naming convention changes with many multiport cards, but it’s safe to use /dev/ttyS0 and /dev/ttyS1 for your COM1 and COM2 ports because most PCs have these two serial ports on their motherboards.


Tip:  
Each serial port on a Linux system actually has two names. For example, COM1 is known as both /dev/ttyS0 and /dev/ttycua0. The second format is used for bidirectional devices such as modems. Don’t use the /dev/cua* devices for printers.


Previous Table of Contents Next