📄 printing-using.html
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta name="generator" content="HTML Tidy, see www.w3.org" /><title>Using Printers</title><meta name="GENERATOR" content="Modular DocBook HTML Stylesheet Version 1.7" /><link rel="HOME" title="FreeBSD 使用手册" href="index.html" /><link rel="UP" title="Printing" href="printing.html" /><link rel="PREVIOUS" title="Advanced Printer Setup" href="printing-advanced.html" /><link rel="NEXT" title="Alternatives to the Standard Spooler"href="printing-lpd-alternatives.html" /><link rel="STYLESHEET" type="text/css" href="docbook.css" /><meta http-equiv="Content-Type" content="text/html; charset=GB2312" /></head><body class="SECT1" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#840084"alink="#0000FF"><div class="NAVHEADER"><table summary="Header navigation table" width="100%" border="0" cellpadding="0"cellspacing="0"><tr><th colspan="3" align="center">FreeBSD 使用手册</th></tr><tr><td width="10%" align="left" valign="bottom"><a href="printing-advanced.html"accesskey="P">Prev</a></td><td width="80%" align="center" valign="bottom">Chapter 11. Printing</td><td width="10%" align="right" valign="bottom"><a href="printing-lpd-alternatives.html"accesskey="N">Next</a></td></tr></table><hr align="LEFT" width="100%" /></div><div class="SECT1"><h1 class="SECT1"><a id="PRINTING-USING" name="PRINTING-USING">11.5. UsingPrinters</a></h1><p>This section tells you how to use printers you have setup with FreeBSD. Here is anoverview of the user-level commands:</p><div class="VARIABLELIST"><dl><dt><span class="CITEREFENTRY"><span class="REFENTRYTITLE">lpr</span>(1)</span></dt><dd><p>Print jobs</p></dd><dt><span class="CITEREFENTRY"><span class="REFENTRYTITLE">lpq</span>(1)</span></dt><dd><p>Check printer queues</p></dd><dt><span class="CITEREFENTRY"><span class="REFENTRYTITLE">lprm</span>(1)</span></dt><dd><p>Remove jobs from a printer's queue</p></dd></dl></div><p>There is also an administrative command, <span class="CITEREFENTRY"><spanclass="REFENTRYTITLE">lpc</span>(8)</span>, described in the section <ahref="printing-using.html#PRINTING-LPC">Administering the <b class="APPLICATION">LPD</b>Spooler</a>, used to control printers and their queues.</p><p>All three of the commands <span class="CITEREFENTRY"><spanclass="REFENTRYTITLE">lpr</span>(1)</span>, <span class="CITEREFENTRY"><spanclass="REFENTRYTITLE">lprm</span>(1)</span>, and <span class="CITEREFENTRY"><spanclass="REFENTRYTITLE">lpq</span>(1)</span> accept an option <var class="OPTION">-P <varclass="REPLACEABLE">printer-name</var></var> to specify on which printer/queue tooperate, as listed in the <tt class="FILENAME">/etc/printcap</tt> file. This enables youto submit, remove, and check on jobs for various printers. If you do not use the <varclass="OPTION">-P</var> option, then these commands use the printer specified in the <ttclass="ENVAR">PRINTER</tt> environment variable. Finally, if you do not have a <ttclass="ENVAR">PRINTER</tt> environment variable, these commands default to the printernamed <var class="LITERAL">lp</var>.</p><p>Hereafter, the terminology <span class="emphasis"><i class="EMPHASIS">defaultprinter</i></span> means the printer named in the <tt class="ENVAR">PRINTER</tt>environment variable, or the printer named <var class="LITERAL">lp</var> when there is no<tt class="ENVAR">PRINTER</tt> environment variable.</p><div class="SECT2"><h2 class="SECT2"><a id="PRINTING-LPR" name="PRINTING-LPR">11.5.1. Printing Jobs</a></h2><p>To print files, type:</p><pre class="SCREEN"><samp class="PROMPT">%</samp> <kbd class="USERINPUT">lpr <varclass="REPLACEABLE">filename</var> <var class="REPLACEABLE">...</var></kbd></pre><p>This prints each of the listed files to the default printer. If you list no files,<span class="CITEREFENTRY"><span class="REFENTRYTITLE">lpr</span>(1)</span> reads data toprint from standard input. For example, this command prints some important systemfiles:</p><pre class="SCREEN"><samp class="PROMPT">%</samp> <kbdclass="USERINPUT">lpr /etc/host.conf /etc/hosts.equiv</kbd></pre><p>To select a specific printer, type:</p><pre class="SCREEN"><samp class="PROMPT">%</samp> <kbd class="USERINPUT">lpr -P <varclass="REPLACEABLE">printer-name</var> <var class="REPLACEABLE">filename</var> <varclass="REPLACEABLE">...</var></kbd></pre><p>This example prints a long listing of the current directory to the printer named <varclass="LITERAL">rattan</var>:</p><pre class="SCREEN"><samp class="PROMPT">%</samp> <kbd class="USERINPUT">ls -l | lpr -P rattan</kbd></pre><p>Because no files were listed for the <span class="CITEREFENTRY"><spanclass="REFENTRYTITLE">lpr</span>(1)</span> command, <tt class="COMMAND">lpr</tt> read thedata to print from standard input, which was the output of the <tt class="COMMAND">ls-l</tt> command.</p><p>The <span class="CITEREFENTRY"><span class="REFENTRYTITLE">lpr</span>(1)</span>command can also accept a wide variety of options to control formatting, apply fileconversions, generate multiple copies, and so forth. For more information, see thesection <a href="printing-using.html#PRINTING-LPR-OPTIONS">Printing Options</a>.</p></div><div class="SECT2"><h2 class="SECT2"><a id="PRINTING-LPQ" name="PRINTING-LPQ">11.5.2. Checking Jobs</a></h2><p>When you print with <span class="CITEREFENTRY"><spanclass="REFENTRYTITLE">lpr</span>(1)</span>, the data you wish to print is put together ina package called a ``print job'', which is sent to the <b class="APPLICATION">LPD</b>spooling system. Each printer has a queue of jobs, and your job waits in that queue alongwith other jobs from yourself and from other users. The printer prints those jobs in afirst-come, first-served order.</p><p>To display the queue for the default printer, type <span class="CITEREFENTRY"><spanclass="REFENTRYTITLE">lpq</span>(1)</span>. For a specific printer, use the <varclass="OPTION">-P</var> option. For example, the command</p><pre class="SCREEN"><samp class="PROMPT">%</samp> <kbd class="USERINPUT">lpq -P bamboo</kbd></pre>shows the queue for the printer named <var class="LITERAL">bamboo</var>. Here is anexample of the output of the <tt class="COMMAND">lpq</tt> command:<br /><br /><pre class="SCREEN">bamboo is ready and printingRank Owner Job Files Total Sizeactive kelly 9 /etc/host.conf, /etc/hosts.equiv 88 bytes2nd kelly 10 (standard input) 1635 bytes3rd mary 11 ... 78519 bytes</pre><p>This shows three jobs in the queue for <var class="LITERAL">bamboo</var>. The firstjob, submitted by user kelly, got assigned ``job number'' 9. Every job for a printer getsa unique job number. Most of the time you can ignore the job number, but you will need itif you want to cancel the job; see section <ahref="printing-using.html#PRINTING-LPRM">Removing Jobs</a> for details.</p><p>Job number nine consists of two files; multiple files given on the <spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">lpr</span>(1)</span> command line aretreated as part of a single job. It is the currently active job (note the word <varclass="LITERAL">active</var> under the ``Rank'' column), which means the printer shouldbe currently printing that job. The second job consists of data passed as the standardinput to the <span class="CITEREFENTRY"><span class="REFENTRYTITLE">lpr</span>(1)</span>command. The third job came from user <tt class="USERNAME">mary</tt>; it is a much largerjob. The pathname of the file she is trying to print is too long to fit, so the <spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">lpq</span>(1)</span> command just showsthree dots.</p><p>The very first line of the output from <span class="CITEREFENTRY"><spanclass="REFENTRYTITLE">lpq</span>(1)</span> is also useful: it tells what the printer iscurrently doing (or at least what <b class="APPLICATION">LPD</b> thinks the printer isdoing).</p><p>The <span class="CITEREFENTRY"><span class="REFENTRYTITLE">lpq</span>(1)</span>command also support a <var class="OPTION">-l</var> option to generate a detailed longlisting. Here is an example of <tt class="COMMAND">lpq -l</tt>:</p><pre class="SCREEN">waiting for bamboo to become ready (offline ?)kelly: 1st [job 009rose] /etc/host.conf 73 bytes /etc/hosts.equiv 15 byteskelly: 2nd [job 010rose] (standard input) 1635 bytesmary: 3rd [job 011rose] /home/orchid/mary/research/venus/alpha-regio/mapping 78519 bytes</pre></div><div class="SECT2"><h2 class="SECT2"><a id="PRINTING-LPRM" name="PRINTING-LPRM">11.5.3. RemovingJobs</a></h2><p>If you change your mind about printing a job, you can remove the job from the queuewith the <span class="CITEREFENTRY"><span class="REFENTRYTITLE">lprm</span>(1)</span>command. Often, you can even use <span class="CITEREFENTRY"><spanclass="REFENTRYTITLE">lprm</span>(1)</span> to remove an active job, but some or all ofthe job might still get printed.</p><p>To remove a job from the default printer, first use <span class="CITEREFENTRY"><spanclass="REFENTRYTITLE">lpq</span>(1)</span> to find the job number. Then type:</p><pre class="SCREEN"><samp class="PROMPT">%</samp> <kbd class="USERINPUT">lprm <varclass="REPLACEABLE">job-number</var></kbd></pre><p>To remove the job from a specific printer, add the <var class="OPTION">-P</var>option. The following command removes job number 10 from the queue for the printer <varclass="LITERAL">bamboo</var>:</p><pre class="SCREEN"><samp class="PROMPT">%</samp> <kbd class="USERINPUT">lprm -P bamboo 10</kbd></pre><p>The <span class="CITEREFENTRY"><span class="REFENTRYTITLE">lprm</span>(1)</span>command has a few shortcuts:</p><div class="VARIABLELIST"><dl><dt>lprm -</dt><dd><p>Removes all jobs (for the default printer) belonging to you.</p></dd><dt>lprm <var class="REPLACEABLE">user</var></dt><dd><p>Removes all jobs (for the default printer) belonging to <varclass="REPLACEABLE">user</var>. The superuser can remove other users' jobs; you canremove only your own jobs.</p></dd><dt>lprm</dt><dd><p>With no job number, user name, or <var class="OPTION">-</var> appearing on the commandline, <span class="CITEREFENTRY"><span class="REFENTRYTITLE">lprm</span>(1)</span>removes the currently active job on the default printer, if it belongs to you. Thesuperuser can remove any active job.</p></dd></dl></div><p>Just use the <var class="OPTION">-P</var> option with the above shortcuts to operateon a specific printer instead of the default. For example, the following command removesall jobs for the current user in the queue for the printer named <varclass="LITERAL">rattan</var>:</p><pre class="SCREEN"><samp class="PROMPT">%</samp> <kbd class="USERINPUT">lprm -P rattan -</kbd></pre><div class="NOTE"><blockquote class="NOTE"><p><b>Note:</b> If you are working in a networked environment, <spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">lprm</span>(1)</span> will let youremove jobs only from the host from which the jobs were submitted, even if the sameprinter is available from other hosts. The following command sequence demonstratesthis:</p><pre class="SCREEN"><samp class="PROMPT">%</samp> <kbd class="USERINPUT">lpr -P rattan myfile</kbd><samp class="PROMPT">%</samp> <kbd class="USERINPUT">rlogin orchid</kbd><samp class="PROMPT">%</samp> <kbd class="USERINPUT">lpq -P rattan</kbd>Rank Owner Job Files Total Sizeactive seeyan 12 ... 49123 bytes2nd kelly 13 myfile 12 bytes<samp class="PROMPT">%</samp> <kbd class="USERINPUT">lprm -P rattan 13</kbd>rose: Permission denied<samp class="PROMPT">%</samp> <kbd class="USERINPUT">logout</kbd><samp class="PROMPT">%</samp> <kbd class="USERINPUT">lprm -P rattan 13</kbd>dfA013rose dequeuedcfA013rose dequeued </pre></blockquote></div></div><div class="SECT2"><h2 class="SECT2"><a id="PRINTING-LPR-OPTIONS" name="PRINTING-LPR-OPTIONS">11.5.4. BeyondPlain Text: Printing Options</a></h2><p>The <span class="CITEREFENTRY"><span class="REFENTRYTITLE">lpr</span>(1)</span>command supports a number of options that control formatting text, converting graphic andother file formats, producing multiple copies, handling of the job, and more. Thissection describes the options.</p><div class="SECT3"><h3 class="SECT3"><a id="PRINTING-LPR-OPTIONS-FORMAT"name="PRINTING-LPR-OPTIONS-FORMAT">11.5.4.1. Formatting and Conversion Options</a></h3><p>The following <span class="CITEREFENTRY"><spanclass="REFENTRYTITLE">lpr</span>(1)</span> options control formatting of the files in thejob. Use these options if the job does not contain plain text or if you want plain textformatted through the <span class="CITEREFENTRY"><spanclass="REFENTRYTITLE">pr</span>(1)</span> utility.</p><p>For example, the following command prints a DVI file (from the TeX typesetting system)named <tt class="FILENAME">fish-report.dvi</tt> to the printer named <varclass="LITERAL">bamboo</var>:</p><pre class="SCREEN"><samp class="PROMPT">%</samp> <kbdclass="USERINPUT">lpr -P bamboo -d fish-report.dvi</kbd></pre><p>These options apply to every file in the job, so you cannot mix (say) DVI and ditrofffiles together in a job. Instead, submit the files as separate jobs, using a differentconversion option for each job.</p><div class="NOTE"><blockquote class="NOTE"><p><b>Note:</b> All of these options except <var class="OPTION">-p</var> and <varclass="OPTION">-T</var> require conversion filters installed for the destination printer.For example, the <var class="OPTION">-d</var> option requires the DVI conversion filter.Section <a href="printing-advanced.html#PRINTING-ADVANCED-CONVFILTERS">ConversionFilters</a> gives details.</p></blockquote></div><div class="VARIABLELIST"><dl><dt><var class="OPTION">-c</var></dt><dd><p>Print cifplot files.</p></dd><dt><var class="OPTION">-d</var></dt><dd><p>Print DVI files.</p></dd><dt><var class="OPTION">-f</var></dt><dd><p>Print FORTRAN text files.</p></dd><dt><var class="OPTION">-g</var></dt><dd><p>Print plot data.</p></dd><dt><var class="OPTION">-i <var class="REPLACEABLE">number</var></var></dt><dd><p>Indent the output by <var class="REPLACEABLE">number</var> columns; if you omit <varclass="REPLACEABLE">number</var>, indent by 8 columns. This option works only withcertain conversion filters.</p><div class="NOTE"><blockquote class="NOTE">
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -