Using the Line Print Daemon

The default print server for Red Hat Linux is CUPS. Since CUPS took over as the default for the first time on Red Hat Linux 9, I assume that many of you still prefer to use the Line Print Daemon (LPD). While LPD has served Linux well, it does not have the capabilities of CUPS with respect to print groups or classes. CUPS allows you to work with IPP, which is the evolving standard for print servers on most operating systems.

The LPD system includes only one RPM package, LPRng-* . If you want to use LPD, install this package. The key LPD configuration file is /etc/printcap , which is part of the basic setup-* RPM package. You can edit this directly or use the redhat-config-printer utility. Once you ve configured a printer, you can maintain that printer directly from the command-line interface with commands such as lpr , lpq , lpc , and lprm .

start sidebar
Setting LPD as the Default

The cupsd daemon is active by default in Red Hat Linux 9. If you prefer LPD, you ll need to deactivate cupsd and activate lpd with the service cups stop and service lpd start commands. Next, deactivate the cups-lpd daemon with the chkconfig cups-lpd off command. Then, switch the print service with the redhat-switch-printer utility.

If you want to make the change permanent, make sure that Linux is set to start lpd at the desired runlevels by using the chkconfig command. See Chapter 13 for more information on chkconfig .

end sidebar

The LPD Configuration Files

While veteran Linux users often edit basic configuration files directly in a text editor, LPD uses fairly obscure commands, as shown in Figure 25.19.

click to expand
Figure 25.19: A sample LPD configuration file ( /etc/printcap )

Red Hat actually includes two configuration files for LPD printers: /etc/printcap and /etc/ printcap.local . If you use redhat-config-printers , the results are written directly to (and overwrites anything in) /etc/printcap .

If you also want to configure printers by directly editing a configuration file, you should type the needed commands into /etc/printcap.local . The contents of this file are included in /etc/printcap when you restart the lpd daemon.

There are a number of programming codes in a typical /etc/printcap file. Some of them are shown in Table 25.13.

Table 25.13: /etc/printcap Programming Codes




Divides code lines in an /etc/printcap command.


Connects two lines together; it escapes the effect of a new line.


Associated with an accounting filter ( af ).


Uses an input filter ( if ) for a specific printer.


Indicates the line print ( lp ) device associated with the printer.


Sends print jobs through a filter if set to true.


Checks for non-printable characters ; if set to a value other than 0, it will prevent printing of most binary files.


Specifies the maximum file size ; if set to 0, there s no limit.


Indicates the spool directory.


Suppresses headers.


Specifies the page length, in lines.


Specifies the page width, in characters.

In other words, there are three command lines in Figure 25.18 ; the backslash is used to continue a command from one line to another. For example, the following commands are read as if they were on the same line:

 printer:\       :ml#0 

There are two other major LPD configuration files. The default versions of these files are good for most purposes. In most cases, you can change what you need in /etc/printcap or in the application that you re using. Since these files are rarely edited, we ll just mention their purpose. The /etc/lpd .conf file notes the default settings for printers. The /etc/lpd.perms file sets permissions for the LPD spooler.


If you re using CUPS, /etc/printcap includes a simple list of configured printers and printer classes.

Printer Management

Four basic commands are associated with the LPD: the Line Printer Request, lpr; the Line Printer Query, lpq; the Line Printer Remove, lprm; and the Line Printer Control, lpc . These are sometimes known as the lp commands.


If you re using CUPS and have activated the cups-lpd service in /etc/xinetd.d , these commands don t work quite the same, but should give you a similar result.


When you have Linux read the contents of a file with the cat command, the shell sends the result to standard output, which normally means that you see the result on your screen. In contrast, when you use lpr , the shell sends the result to a spool file on the local computer, then on to a print server computer, and finally to the printer. The lpr command is effectively a client. When it produces a spool file, the result is processed by the lpd server on a local or remote network.

Therefore, when you run a command such as lpr file , the shell sends the result to the default printer as configured in /etc/printcap . Alternatively, you can send the print job to a different printer.

For example, if colorprinter is configured in /etc/printcap , the following command sends the job to that printer:

 # lpr -Pcolorprinter  file1  

When using the lpr command to specify a printer, there s no space between the -P and the name of the printer.

Other variations on the lpr command are shown in Table 25.14.

Table 25.14: lpr Commands



lpr -h file1

Prints file1 without a job control page, which normally contains the user account and hostname of the source computer. The job control page is also known as the burst page.

lpr -P other file1

Prints file1 to the printer named other , as defined in the /etc/printcap file.

lpr -s file1

Creates a symbolic link to file1 , which avoids creating a spool file. This was required for larger (>1MB) files on the Berkeley Standard Distribution version of lpr . Red Hat Linux 9 uses the LPRng program, which makes this unnecessary.


The lpq command gives you the current print queue. There are three basic options, as shown in Table 25.15. This command also includes a list of job numbers , which you might need for the lprm command.

Table 25.15: lpq Command Examples




Returns the current print queue for the default printer, as defined in your /etc/ printcap file.

lpq -P printer

Returns the print queue for the named printer . Uses the name as defined in your /etc/printcap file.


If a print job isn t already in your printer s memory, the lprm command can delete print jobs currently in your queue. With lprm , you can remove a print job in one of three ways: by print job number, by user, or by printer. Table 25.16 shows examples of this command.

Table 25.16: lprm Command Examples



lprm 188

Removes print job 188, as defined in the output to the lpq command

lprm -P hp2 mj

Removes print jobs of user mj from the printer labeled hp2 in your /etc/printcap file


The lpc command allows you to control a number of characteristics of each printer. As shown in Table 25.17, this command lets you check printer status, kill active print jobs, or even redirect jobs to a different printer.

Table 25.17: lpc Command Examples



lpc -P canon1 status

Displays the status of the printer named canon1 . In other words, the output tells you whether you can send print jobs to a queue, the number of jobs in the queue, whether the printer will accept jobs, and communication status with the printer.

lpc disable

Disables sending jobs ( spooling ) to a print queue for the default printer. Opposite of lpc enable .

lpc start

Restarts transfers from the print queue.

lpc stop

Stops communication between the print queue and your printer.


Mastering Red Hat Linux 9
Building Tablet PC Applications (Pro-Developer)
ISBN: 078214179X
EAN: 2147483647
Year: 2005
Pages: 220 © 2008-2017.
If you may any questions please contact us: