📄 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 Handbook" 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" /></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 Handbook</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 9 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">9.5 UsingPrinters</a></h1><p>This section tells you how to use printers you have set up with FreeBSD. Here is anoverview of the user-level commands:</p><div class="VARIABLELIST"><dl><dt><a href="http://www.FreeBSD.org/cgi/man.cgi?query=lpr&sektion=1"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">lpr</span>(1)</span></a></dt><dd><p>Print jobs</p></dd><dt><a href="http://www.FreeBSD.org/cgi/man.cgi?query=lpq&sektion=1"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">lpq</span>(1)</span></a></dt><dd><p>Check printer queues</p></dd><dt><a href="http://www.FreeBSD.org/cgi/man.cgi?query=lprm&sektion=1"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">lprm</span>(1)</span></a></dt><dd><p>Remove jobs from a printer's queue</p></dd></dl></div><p>There is also an administrative command, <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=lpc&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">lpc</span>(8)</span></a>, described inthe section <a href="printing-using.html#PRINTING-LPC">Administering the <bclass="APPLICATION">LPD</b> Spooler</a>, used to control printers and their queues.</p><p>All three of the commands <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=lpr&sektion=1"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">lpr</span>(1)</span></a>, <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=lprm&sektion=1"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">lprm</span>(1)</span></a>, and <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=lpq&sektion=1"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">lpq</span>(1)</span></a> accept anoption <var class="OPTION">-P <var class="REPLACEABLE">printer-name</var></var> tospecify on which printer/queue to operate, as listed in the <ttclass="FILENAME">/etc/printcap</tt> file. This enables you to submit, remove, and checkon jobs for various printers. If you do not use the <var class="OPTION">-P</var> option,then these commands use the printer specified in the <tt class="ENVAR">PRINTER</tt>environment variable. Finally, if you do not have a <tt class="ENVAR">PRINTER</tt>environment variable, these commands default to the printer named <varclass="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">9.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, <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=lpr&sektion=1"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">lpr</span>(1)</span></a> 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 <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=lpr&sektion=1"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">lpr</span>(1)</span></a> command, <ttclass="COMMAND">lpr</tt> read the data to print from standard input, which was the outputof the <tt class="COMMAND">ls -l</tt> command.</p><p>The <a href="http://www.FreeBSD.org/cgi/man.cgi?query=lpr&sektion=1"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">lpr</span>(1)</span></a> command canalso accept a wide variety of options to control formatting, apply file conversions,generate multiple copies, and so forth. For more information, see the section <ahref="printing-using.html#PRINTING-LPR-OPTIONS">Printing Options</a>.</p></div><div class="SECT2"><h2 class="SECT2"><a id="PRINTING-LPQ" name="PRINTING-LPQ">9.5.2 Checking Jobs</a></h2><p>When you print with <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=lpr&sektion=1"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">lpr</span>(1)</span></a>, the data youwish to print is put together in a package called a ``print job'', which is sent to the<b class="APPLICATION">LPD</b> spooling system. Each printer has a queue of jobs, andyour job waits in that queue along with other jobs from yourself and from other users.The printer prints those jobs in a first-come, first-served order.</p><p>To display the queue for the default printer, type <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=lpq&sektion=1"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">lpq</span>(1)</span></a>. For a specificprinter, use the <var class="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 <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=lpr&sektion=1"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">lpr</span>(1)</span></a> command lineare treated 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 <a href="http://www.FreeBSD.org/cgi/man.cgi?query=lpr&sektion=1"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">lpr</span>(1)</span></a> command. Thethird job came from user <tt class="USERNAME">mary</tt>; it is a much larger job. Thepathname of the file she is trying to print is too long to fit, so the <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=lpq&sektion=1"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">lpq</span>(1)</span></a> command justshows three dots.</p><p>The very first line of the output from <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=lpq&sektion=1"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">lpq</span>(1)</span></a> is also useful:it tells what the printer is currently doing (or at least what <bclass="APPLICATION">LPD</b> thinks the printer is doing).</p><p>The <a href="http://www.FreeBSD.org/cgi/man.cgi?query=lpq&sektion=1"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">lpq</span>(1)</span></a> command alsosupport a <var class="OPTION">-l</var> option to generate a detailed long listing. Hereis 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">9.5.3 Removing Jobs</a></h2><p>If you change your mind about printing a job, you can remove the job from the queuewith the <a href="http://www.FreeBSD.org/cgi/man.cgi?query=lprm&sektion=1"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">lprm</span>(1)</span></a> command.Often, you can even use <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=lprm&sektion=1"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">lprm</span>(1)</span></a> to remove anactive job, but some or all of the job might still get printed.</p><p>To remove a job from the default printer, first use <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=lpq&sektion=1"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">lpq</span>(1)</span></a> to find the jobnumber. 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 <a href="http://www.FreeBSD.org/cgi/man.cgi?query=lprm&sektion=1"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">lprm</span>(1)</span></a> command has afew 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>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -