📄 lsg19.htm
字号:
<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<SCRIPT>
<!--
function displayWindow(url, width, height) {
var Win = window.open(url,"displayWindow",'width=' + width +
',height=' + height + ',resizable=1,scrollbars=yes');
}
//-->
</SCRIPT>
</HEAD>
-->
<LINK REL="ToC" HREF="index.htm">
<LINK REL="Index" HREF="htindex.htm">
<LINK REL="Next" HREF="lsg20.htm">
<A NAME="I0"></A>
<H2>Linux System Administrator's Survival Guide lsg19.htm</H2>
<P ALIGN=LEFT>
<HR ALIGN=CENTER>
<P>
<UL>
<UL>
<UL>
<LI>
<A HREF="#E68E103" >Adding Printers</A>
<LI>
<A HREF="#E68E104" >Understanding the lpd Printing Daemon</A>
<UL>
<LI>
<A HREF="#E69E135" >Print Spoolers</A>
<LI>
<A HREF="#E69E136" >The Printing Process</A>
<LI>
<A HREF="#E69E137" >The /etc/printcap File</A></UL>
<LI>
<A HREF="#E68E105" >Managing Printers with lpc</A>
<LI>
<A HREF="#E68E106" >Managing the Printer Queue with lpq and lprm</A>
<LI>
<A HREF="#E68E107" >Summary</A></UL></UL></UL>
<HR ALIGN=CENTER>
<A NAME="E66E22"></A>
<H1 ALIGN=CENTER>
<CENTER>
<FONT SIZE=6 COLOR="#FF0000"><B>Chapter 19</B></FONT></CENTER></H1>
<BR>
<A NAME="E67E25"></A>
<H2 ALIGN=CENTER>
<CENTER>
<FONT SIZE=6 COLOR="#FF0000"><B>Printers and Print Spoolers</B></FONT></CENTER></H2>
<BR>
<P>Printers can cause quite a few problems for system administrators because the configuration and handling of a printer under Linux is considerably different than under DOS or OS/2. The unintuitive nature of the printer commands also complicates the handling of printers and print systems. Despite these quibbles, printers are quite easy to configure as long as you know a little about Linux, device drivers, and the printers you are using. Managing the printer queues is also relatively easy, but like many things in Linux, you must know the tricks to make the system work for you.
<BR>
<P>The printing capabilities of Linux are not as powerful and easy-to-use as most commercial versions of UNIX. Linux is based on BSD UNIX, which is not the most talented version with respect to printer administration. Luckily, few users use more than one or two printers in a typical parallel-port or serial-port based installation, so administration requirements are simplified enormously. When you work with large networked printer environments, however, Linux's limitations in this area are more apparent. A word of warning: Linux's printer administration routines have a reputation for quirky behavior, such as suddenly stopping the print spooler for no apparent reason!
<BR>
<BR>
<A NAME="E68E103"></A>
<H3 ALIGN=CENTER>
<CENTER>
<FONT SIZE=5 COLOR="#FF0000"><B>Adding Printers</B></FONT></CENTER></H3>
<BR>
<P>Linux supports both parallel and serial printers, as well as network printers (available from another machine on the local area network). Most parallel and serial printers are character mode devices, although a few high-speed printers are block mode devices (although block mode printers are usually much too expensive for a small Linux-based system). Unfortunately, Linux does not have a simple-to-use printer installation and configuration utility like many UNIX versions, so you must create printer devices and files manually. (A few printer installation and configuration scripts are beginning to appear, although they are not in general use yet.)
<BR>
<P>Parallel printers are referred to as devices /dev/lp0, /dev/lp1, or /dev/lp2, depending on the number of the parallel port with which they are used. Most printers attached to a PC parallel port are attached to /dev/lp0, the first parallel device.
<BR>
<TABLE BORDERCOLOR=#000040 BORDER=1 CELLSPACING=2 WIDTH="100%" CELLPADDING=2 >
<TR>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
Parallel port device
</FONT>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
I/O address
</FONT>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
DOS equivalent</FONT>
<TR>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
/dev/lp0
</FONT>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
0x03bc
</FONT>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
LPT1</FONT>
<TR>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
/dev/lp1
</FONT>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
0x0378
</FONT>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
LPT2</FONT>
<TR>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
/dev/lp2
</FONT>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
0x0278
</FONT>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
LPT3</FONT>
</TABLE><BLOCKQUOTE>
<BLOCKQUOTE>
<HR ALIGN=CENTER>
<BR>
<NOTE>To determine the address of a parallel port, you can use a diagnostic utility (such as DOS' MSD.EXE or Norton Utilities). Some BIOS versions display port addresses when the system is booting. If you are unsure what the address is, try the parallel ports in order, starting with /dev/lp0, and see whether a printout is possible from that port.</NOTE>
<BR>
<HR ALIGN=CENTER>
</BLOCKQUOTE></BLOCKQUOTE>
<P>Linux uses the mknod (make node) command to create a parallel printer device. The command to make a parallel printer device on the first parallel port (/dev/lp0) is
<BR>
<BR>
<PRE>
<FONT COLOR="#000080">mknod -m 620 /dev/lp0 c 6 0</FONT></PRE>
<P>In this example, the device /dev/lp0 is created as a character mode device with major device number six and minor device number zero. (See <A HREF="lsg06.htm">Chapter 6</A>, "Devices and Device Drivers" for more information about device drivers and device numbers.) Usually, minor device numbers start at zero and are incremented upwards. Because this printer is the first one added, the minor device number is set to zero. The -m option sets the file permission mask (to 620 in this case).
<BR>
<P>After you create the printer device driver file, you must change the ownership of the device driver to root, daemon, or root.daemon. The owner root is a good default value, but root.daemon is better because it adds a little more security to the ownerships by setting the owner to root and the group to daemon with a single command:
<BR>
<BR>
<PRE>
<FONT COLOR="#000080">chown root.daemon /dev/lp0</FONT></PRE>
<P>After changing the ownership of the file, check the file permissions. Set them to mode 620 by using the following command:
<BR>
<BR>
<PRE>
<FONT COLOR="#000080">chmod 620 /dev/lp0</FONT></PRE>
<BLOCKQUOTE>
<BLOCKQUOTE>
<HR ALIGN=CENTER>
<BR>
<NOTE>The ownership root.daemon is a special Linux convention for the daemons run by root. The entry root.daemon does not appear in the /etc/passwd file, but it is legal. This syntax sets the owner and group at the same time. The owner is the first part of the entry, and the group follows a period. The entry root.daemon sets the owner to root and the group to daemon.</NOTE>
<BR>
<HR ALIGN=CENTER>
</BLOCKQUOTE></BLOCKQUOTE>
<P>To configure a device other than the first parallel port (/dev/lp0), you must change the device name itself to the device number. For each possible parallel port, the mknod commands are as follows:
<BR>
<PRE>
<FONT COLOR="#000080">mknod -m 620 /dev/lp0 c 6 0
mknod -m 620 /dev/lp1 c 6 1
mknod -m 620 /dev/lp2 c 6 2</FONT></PRE>
<P>In these examples, the minor device numbers have been incremented to correspond to the port number. Although numbering the devices in this manner is not absolutely necessary, it can help with identification when you want to know which port the device is hanging off of.
<BR>
<P>After issuing the mknod and chown commands, check to ensure that the ownerships are set properly. You should also create a spool directory for the printer. The permissions and ownership requirements of the spool directory are important and are discussed in "The /etc/printcap File" section later in this chapter.
<BR>
<BR>
<A NAME="E68E104"></A>
<H3 ALIGN=CENTER>
<CENTER>
<FONT SIZE=5 COLOR="#FF0000"><B>Understanding the lpd Printing Daemon</B></FONT></CENTER></H3>
<BR>
<P>Printing services are handled by a daemon called lpd (line printer daemon). The lpd daemon is usually started automatically in the /etc/rc boot process when the system moves to multiuser mode. The lpd daemon handles a number of tasks and keeps running as long as Linux is active (unless terminated by the superuser or a daemon crash). One of the important parts of the daemon's startup procedures is to read the printer configuration file, /etc/printcap.
<BR>
<P>The /etc/printcap file is used to identify instructions for communicating with all the printers that are configured and attached to the system (in the same manner that /etc/termcap contains terminal definitions). Once it has started itself, lpd starts up two other daemons called listen and accept that handle any incoming print request.
<BR>
<P>You probably won't ever have to modify the lpd daemon. Because the Linux daemon is a little unstable, though, you may have to restart or terminate it while you make some configuration changes. To start the lpd daemon, use this syntax:
<BR>
<BR>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -