📄 405-408.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=405-408//-->
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="../ch19/402-403.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="408-410.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<H2><A NAME="Heading1"></A><FONT COLOR="#000077">Chapter 20<BR>Printing
</FONT></H2>
<P><I>by Jack Tackett</I></P>
<DL>
<DT><B><BIG>I</BIG>n this chapter
</B><DT>Selecting a Printer to Work with Linux
<DT>Knowing What You Need to Configure Printers
<DT>Knowing How Printing Works Under Linux
<DT>Understanding the Important Programs for Printing
<DT>Understanding the Important Directories
<DT>Understanding the Important Files
<DT>Understanding the /etc/printcap File
<DT>Creating a Test printcap Entry
<DT>Putting It All Together
<DT>Configuring Red Hat Printers
</DL>
<P>Although everyone thought the computer revolution would bring the paperless office, it hasn’t. More paper is used today than was used 20 years ago. When the UNIX operating system was in its infancy, Bell Labs used it to produce—and print—technical documentation. As a result, UNIX, and thus Linux, has a great many utilities designed around printing (or at least formatting data to be printed). This chapter concentrates on the mechanics of actually printing a file.
</P>
<P>The printing systems common to BSD UNIX/Linux are called the <I>lpr systems (Line PrinteR)</I>.</P>
<H3><A NAME="Heading2"></A><FONT COLOR="#000077">Selecting a Printer to Work with Linux</FONT></H3>
<P>If you can access the printer from MS-DOS, you should be able to print ASCII characters to the printer from Linux. The only downside is that you may not be able to access certain features of your printer from Linux. One of the main reasons is that under Linux, the system first sends the file to be printed to another file. Linux sends the files to a temporary area because printers are relatively slow peripherals, and the system doesn’t want to slow down your session just to print a file. This process is called <I>spooling</I>, and printers are thus called <I>spooled devices</I>. When you print a file in Linux, the file doesn’t go directly to a printer; instead, it goes to a queue to wait its turn to be printed. If your file is the first in the queue, it prints almost immediately.</P>
<BLOCKQUOTE>
<P><FONT SIZE="-1"><HR><B>NOTE: </B><TT>Spool</TT> is an acronym for Simultaneous Peripheral Operation Off Line. The term was coined in the early days of the big IBM mainframes, when smaller computers were used to print reports offline from the mainframe. This technique allowed expensive mainframes to continue their tasks without wasting time on such trivial matters as printing.<HR></FONT>
</BLOCKQUOTE>
<P>Because Linux inherits a great deal of UNIX functionality, Linux supports many types of printers. If you can access your printer from DOS (as mentioned earlier), you should be able to access the printer from Linux.
</P>
<H3><A NAME="Heading3"></A><FONT COLOR="#000077">Knowing What You Need to Configure Printers</FONT></H3>
<P>This chapter assumes that you know how to edit a text file under Linux and that you have a basic understanding of file ownership and permissions. It also assumes that you have your Linux system set up and running correctly. In particular, if you’re going to use remote printing, your networking subsystems must be installed and operating correctly. Check out the man pages on the commands <TT>chmod</TT> and <TT>chown</TT> for more information. Also review Chapter 8, “Using the <TT>vi</TT> Editor,” for information on using the <TT>vi</TT> editor because you need to edit several files when configuring your printers.</P>
<H3><A NAME="Heading4"></A><FONT COLOR="#000077">Knowing How Printing Works Under Linux</FONT></H3>
<P>The simplest way to print under Linux is to send the print data directly to the printer device. The following command sends a directory listing to the first parallel printer (LPT1 in DOS terms):
</P>
<!-- CODE SNIP //-->
<PRE>
ls > /dev/lp0
</PRE>
<!-- END CODE SNIP //-->
<P>This method doesn’t take advantage of Linux’s multitasking capabilities because the time taken for this command to finish is however long it takes the printer to actually physically print the data. On a slow printer or a printer that’s deselected or disconnected, this could be a long time. A better method is to <I>spool</I> the data—that is, to collect the print data into a file and then start a background process to send the data to the printer.</P>
<P>Spooling files to be printed later is essentially how Linux works. For each printer, a spool area is defined. Data for the printer is collected in the spool area, one file per print job. A background process (called the <I>printer daemon</I>) constantly scans the spool areas for new files to print. When one appears, the data is sent to the appropriate printer, or <I>despooled</I>. When more than one file is waiting to be printed, the files are printed in the order they’re completed—first in, first out. Thus, the spool area is effectively a queue, and the waiting jobs are often referred to as being <I>in the print queue</I> or <I>queued</I>. In the case of remote printing, the data is first spooled locally as for any other print job, but the background process is told to send the data to a particular printer on a particular remote machine.</P>
<P>The necessary information that the printer daemon needs to do its job—the physical device to use, the spool area to look in, the remote machine and printer for remote printing, and so on—is all stored in a file called /etc/printcap. The details of this file are discussed later in the section “Understanding the /etc/printcap File.”</P>
<BLOCKQUOTE>
<P><FONT SIZE="-1"><HR><B>NOTE: </B>To Linux, the printer is just another file. But because it is a physical piece of hardware, it will have an entry in the /dev directory. Linux likes to treat physical devices as if they are part of the file system.<HR></FONT>
</BLOCKQUOTE>
<P>The term <I>printer</I> is used to mean a printer as specified in /etc/printcap. The term <I>physical printer</I> is used to mean the thing that actually puts characters on paper. It’s possible to have multiple entries in /etc/printcap that all describe one physical printer but do so in different ways. If this isn’t clear to you, read the section on /etc/printcap.</P>
<H3><A NAME="Heading5"></A><FONT COLOR="#000077">Understanding the Important Programs for Printing</FONT></H3>
<P>Five programs comprise the UNIX print system. By default, they are in the locations shown in Table 20.1, are owned by root, belong to the group <TT>daemon</TT>, and have the permissions listed in the table.</P>
<TABLE WIDTH="100%"><CAPTION ALIGN=LEFT><B>Table 20.1</B> The Important Printing Programs
<TR>
<TH COLSPAN="2"><HR>
<TR>
<TH WIDTH="30%" ALIGN="LEFT">File Permissions
<TH WIDTH="70%" ALIGN="LEFT">File Locations
<TR>
<TD COLSPAN="2"><HR>
<TR>
<TD>-rwsr-sr-x
<TD>/usr/bin/lpr
<TR>
<TD>-rwsr-sr-x
<TD>/usr/bin/lpq
<TR>
<TD>-rwsr-sr-x
<TD>/usr/bin/lpc
<TR>
<TD>-rwsr-sr-x
<TD>/usr/bin/lprm
<TR>
<TD>-rwxr-s- - -
<TD>/usr/sbin/lpd
<TR>
<TD COLSPAN="2"><HR>
</TABLE>
<P>The first four file permissions in Table 20.1 are used to submit, cancel, and inspect print jobs. /usr/sbin/lpd is the printer daemon.
</P>
<BLOCKQUOTE>
<P><FONT SIZE="-1"><HR><B>NOTE: </B>The locations, ownerships, and permissions in Table 20.1 have been simplified and may be wrong for your system, so note the <TT>lpd</TT> files and permissions.<HR></FONT>
</BLOCKQUOTE>
<P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="../ch19/402-403.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="408-410.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 + -