📄 408-410.html
字号:
<HTML>
<HEAD>
<TITLE>Special Edition Using Linux, Fourth Edition:Printing</TITLE>
<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>
-->
<!--ISBN=0789717468//-->
<!--TITLE=Special Edition Using Linux, Fourth Edition//-->
<!--AUTHOR=Jack Tackett//-->
<!--AUTHOR=Jr.//-->
<!--AUTHOR=Steve Burnett//-->
<!--PUBLISHER=Macmillan Computer Publishing//-->
<!--IMPRINT=Que//-->
<!--CHAPTER=20//-->
<!--PAGES=408-410//-->
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="405-408.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="410-412.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<P>All these commands have man pages, which you should consult for more information. The important points are that by default, <TT>lpr</TT>, <TT>lprm</TT>, <TT>lpc</TT>, and <TT>lpq</TT> operate on a printer called <TT>lp</TT>. If you define an environment variable called <TT>PRINTER</TT>, the name defined is used instead. You can override <TT>lp</TT> and the <TT>PRINTER</TT> environment variable by specifying the printer name to use on the command line like so:</P>
<!-- CODE SNIP //-->
<PRE>
lpc -PMYPRINTER
</PRE>
<!-- END CODE SNIP //-->
<H4 ALIGN="LEFT"><A NAME="Heading6"></A><FONT COLOR="#000077">The <I>lpd</I> Daemon
</FONT></H4>
<P>Linux handles all print jobs via the <TT>lpd</TT> daemon. If this process isn’t running, no printing can take place; print files will remain in their spool directories until the <TT>lpd</TT> process is started (more information about spool directories appears later in the section “Understanding the Important Directories”).</P>
<BLOCKQUOTE>
<P><FONT SIZE="-1"><HR>• <B>See</B> “Understanding Processes,” <B>p. 349</B><HR></FONT>
</BLOCKQUOTE>
<P>If your system doesn’t load <TT>lpd</TT> at startup, or if for some reason you must kill and then restart the <TT>lpd</TT> daemon, the following command starts the printer daemon:</P>
<!-- CODE SNIP //-->
<PRE>
lpd [<I>options</I>]
</PRE>
<!-- END CODE SNIP //-->
<P>The man page on <TT>lpd</TT> gives a list of options, but one important option when configuring your Linux printers is <TT>-l</TT>, which creates a log file that logs each print request to the system. This log file can be useful when you’re debugging your printing system.</P>
<H4 ALIGN="LEFT"><A NAME="Heading7"></A><FONT COLOR="#000077">The <I>lpr</I> Command
</FONT></H4>
<P>The <TT>lpr</TT> command submits a job to the printer, or queues a print job. What actually happens is that the file you specify is copied to the spool directory. Each printer specified for your Linux system must have its own spool directory. The size of this spool directory is specified in the minfree file located in each directory. The minfree file specifies the number of disk blocks to reserve for spooling files to the printer. This is done to keep the <TT>lpd</TT> daemon from using up the entire hard drive when spooling a print request.</P>
<P><TT>lpd</TT> finds the file, which then takes care of moving the data to the physical printer. If you don’t specify a file, <TT>lpr</TT> uses standard input.</P>
<H4 ALIGN="LEFT"><A NAME="Heading8"></A><FONT COLOR="#000077">The <I>lpq</I> Command
</FONT></H4>
<P>The <TT>lpq</TT> command shows you the contents of the spool directory for a given printer. One important piece of information displayed by <TT>lpq</TT> is the job ID, which identifies a particular job. This number must be specified if you want to cancel a pending job.</P>
<P><TT>lpq</TT> also indicates with a number a rank for each job in the queue (meaning, where the job is in the queue). <TT>active</TT> means the file is actually printing—or at least that <TT>lpd</TT> is trying to print it.</P>
<H4 ALIGN="LEFT"><A NAME="Heading9"></A><FONT COLOR="#000077">The <I>lprm</I> Command
</FONT></H4>
<P>The <TT>lprm</TT> command removes a job from the queue—that is, it removes unprinted files from the spool directory. You can specify a job ID (obtained by using the <TT>lpq</TT> command), or you can specify - as the job ID to cancel all jobs belonging to you.</P>
<P>If you issue <TT>lpq -</TT> as root, all jobs for the printer are canceled. If you are root and want to remove all the jobs belonging to a specific user, specify the user’s name.</P>
<H4 ALIGN="LEFT"><A NAME="Heading10"></A><FONT COLOR="#000077">The <I>lpc</I> Command
</FONT></H4>
<P>The <TT>lpc</TT> command lets you check the status of printers and control some aspects of their use. In particular, <TT>lpc</TT> lets you start and stop despooling on printers, enable or disable printers, and rearrange the order of jobs in a print queue. The following commands disable printing on myprinter, enable the spool queue on yourprinter, and move job number 37 to the top of the queue:</P>
<!-- CODE SNIP //-->
<PRE>
lpc down myprinter
lpc enable yourprinter
lpc topq 37
</PRE>
<!-- END CODE SNIP //-->
<P>If you invoke <TT>lpc</TT> without any command arguments, <TT>lpc</TT> is interactive, prompting you for actions to take. Some of the more important commands are shown in Table 20.2; read the man page for complete instructions. Most <TT>lpc</TT> commands take the name of the printer, as specified in /etc/printcap, as the parameter.</P>
<TABLE WIDTH="100%"><CAPTION ALIGN=LEFT><B>Table 20.2</B> Some Common <TT>lpc</TT> Commands
<TR>
<TH COLSPAN="3"><HR>
<TR>
<TH WIDTH="18%" ALIGN="LEFT">Command
<TH WIDTH="17%" ALIGN="LEFT">Parameter
<TH WIDTH="65%" ALIGN="LEFT">Description
<TR>
<TD COLSPAN="3"><HR>
<TR>
<TD VALIGN="TOP"><TT>stop</TT>
<TD VALIGN="TOP"><TT><I>printer</I></TT>
<TD>Stops the printer, but print requests are still spooled.
<TR>
<TD VALIGN="TOP"><TT>start</TT>
<TD VALIGN="TOP"><TT><I>printer</I></TT>
<TD>Allows the printer to start printing previously spooled files and any new files spooled to this printer.
<TR>
<TD><TT>exit, quit</TT>
<TD>(None)
<TD>Leaves <TT>lpc</TT> interactive mode.
<TR>
<TD VALIGN="TOP"><TT>status</TT>
<TD VALIGN="TOP"><TT><I>printer</I></TT>
<TD>Displays the current status of the printer. <TT>status</TT> provides such information as whether the queue is enabled, whether the printer is enabled, and the number (if any) of jobs now in the queue waiting to be printed.
<TR>
<TD COLSPAN="3"><HR>
</TABLE>
<BLOCKQUOTE>
<P><FONT SIZE="-1"><HR><B>NOTE: </B>Bear in mind that some <TT>lpc</TT> commands are restricted to root—that is, the superuser.<HR></FONT>
</BLOCKQUOTE>
<BLOCKQUOTE>
<P><FONT SIZE="-1"><HR><B>CAUTION: </B><BR><TT>lpc</TT> is very unstable in its current implementation under Linux. Some users have reported that <TT>lpc</TT> can display incorrect status messages and sometimes even hang the system outright.<HR></FONT>
</BLOCKQUOTE>
<H3><A NAME="Heading11"></A><FONT COLOR="#000077">Understanding the Important Directories</FONT></H3>
<P>There’s only one important directory in printing—the spool area where data to be printed is accumulated before /etc/lpd prints it. However, a system is typically set up with multiple spool directories, one for each printer, to make printer management easier. For example, my system is set up to use /usr/spool/lpd as the main spool area, with each separate printer having a directory under that with the same name as the printer. Thus, a printer named ps_nff has /usr/spool/lpd/ps_nff as its spool directory.
</P>
<P>The spool directories should belong to the daemon group and should be user and group read/writable and world readable—that is, after you create the directory, make sure that it has the permissions -rwxrwxr-x (0775) with the <TT>chmod</TT> command. For the directory myprinter, the appropriate command is this:</P>
<!-- CODE SNIP //-->
<PRE>
chmod ug=rwx,o=rx myprinter
chgrp daemon myprinter
</PRE>
<!-- END CODE SNIP //-->
<BLOCKQUOTE>
<P><FONT SIZE="-1"><HR>• <B>See</B> “File Permissions,” <B>p. 310</B><HR></FONT>
</BLOCKQUOTE>
<BLOCKQUOTE>
<P><FONT SIZE="-1"><HR><B>NOTE: </B>The locations, ownerships, and permissions given here are a simplification and may be incorrect for your system, so you should take notes on the <TT>lpd</TT> files and permissions.<HR></FONT>
</BLOCKQUOTE>
<P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="405-408.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="410-412.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
</td>
</tr>
</table>
<!-- begin footer information -->
</body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -