586-588.html
来自「linux-unix130.linux.and.unix.ebooks130 l」· HTML 代码 · 共 98 行
HTML
98 行
<HTML>
<HEAD>
<TITLE>Linux Unleashed, Third Edition:Devices</TITLE>
<SCRIPT>
<!--
function displayWindow(url, width, height) {
var Win = window.open(url,"displayWindow",'width=' + width +
',height=' + height + ',resizable=1,scrollbars=yes');
}
//-->
</SCRIPT>
</HEAD>
-->
<!--ISBN=0672313723//-->
<!--TITLE=Linux Unleashed, Third Edition//-->
<!--AUTHOR=Tim Parker//-->
<!--PUBLISHER=Macmillan Computer Publishing//-->
<!--IMPRINT=Sams//-->
<!--CHAPTER=33//-->
<!--PAGES=586-588//-->
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="583-586.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="589-591.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<H4 ALIGN="LEFT"><A NAME="Heading4"></A><FONT COLOR="#000077">The mknod Command</FONT></H4>
<P>The <TT>mknod</TT> (make node) command is used for several different purposes in Linux. It can create a FIFO (first in first out) pipe or a character or block mode device file. The format of this command is</P>
<!-- CODE SNIP //-->
<PRE>
mknod [<I>options</I>] <I>device</I> b|c|p|u <I>major minor</I>
</PRE>
<!-- END CODE SNIP //-->
<P>The options can be one of the following:
</P>
<DL>
<DD><TT>--help</TT> displays help information and then exits.
<DD><TT>-m [mode]</TT> sets the mode of the file to <TT>mode</TT> instead of the default <TT>0666</TT> (only sym-
<DD>bolic notation is allowed).
<DD><TT>--version</TT> displays version information, then exits.
</DL>
<P>The argument after the device or pathname specifies whether the file is a block mode device (<TT>b</TT>), character mode device (<TT>c</TT>), FIFO device (<TT>p</TT>), or unbuffered character mode device (<TT>u</TT>). One of these arguments must be present on the command line.</P>
<P>Following the type of file argument are two numbers for the major and minor device numbers assigned to the new file. Every device on a UNIX system has a unique number that identifies the type of device (the major number) and the specific device itself (the minor number). Both a major and a minor number must be specified for any new block, character, or unbuffered mode device. Device numbers are not specified for a type <TT>p</TT> device.</P>
<P>Examples of using the <TT>mknod</TT> command are shown in several sections later in this chapter, when devices are added to the system.</P>
<H3><A NAME="Heading5"></A><FONT COLOR="#000077">Printer Administration</FONT></H3>
<P>Printers are commonly used devices that can cause a few problems for system administrators. They are quite easy to configure as long as you know something about the hardware. Managing printer queues is also quite easy, but like many things in Linux, you must know the tricks to make the system work easily for you.
</P>
<P>Linux is based on the BSD version of UNIX, which unfortunately is not the most talented UNIX version when it comes to printer administration. However, because it’s unlikely that the Linux system will be used on very large networks with many printers, administration tasks can be reduced to the basics. Be warned, though, that the BSD UNIX printer administration and maintenance commands have a reputation for quirky and inconsistent behavior!</P>
<H4 ALIGN="LEFT"><A NAME="Heading6"></A><FONT COLOR="#000077">The lpd Printing Daemon</FONT></H4>
<P>All printing on the Linux system is handled by the <TT>lpd</TT> daemon, which is usually started when the system boots. During the startup process, the <TT>lpd</TT> daemon reads through the file <TT>/etc/printcap</TT> to identify the sections that apply to any of the printers known to be attached to the system. The <TT>lpd</TT> daemon uses two other processes, called <I>listen</I> and <I>accept</I>, to handle incoming requests for printing and to copy them to a spooling area.</P>
<P>In most cases, you won’t have to modify the <TT>lpd</TT> daemon. However, there might be times when you have to stop it manually and restart it. The command to load <TT>lpd</TT> is</P>
<!-- CODE SNIP //-->
<PRE>
lpd [-l] [<I>port</I>]
</PRE>
<!-- END CODE SNIP //-->
<P>The <TT>-l</TT> option invokes a logging system that notes each print request. This option can be useful when you’re debugging the printer system. The port number allowed in the <TT>lpd</TT> command line is used to specify the Internet port number if the system configuration information is to be overridden. You will probably never have to use it.</P>
<P>The size of the print spool area is set by an entry in the file <TT>minfree</TT> in each spool directory (each printer has its own spool directory). The contents of <TT>minfree</TT> show the number of disk blocks to keep reserved so that spooling large requests doesn’t fill up the hard drive. The contents of the file can be changed with any editor.</P>
<P>Access to the <TT>lpd</TT> daemon to allow printing of a user request must pass a quick validation routine. Two files are involved: <TT>/etc/hosts.equiv</TT> and <TT>/etc/hosts.lpd</TT>. If the machine name of the sending user is not in either file, the print requests are refused. Because the local machine is always in <TT>hosts.equiv</TT> (as <TT>localhost</TT>), users on the Linux machine should always have their print requests granted.</P>
<H4 ALIGN="LEFT"><A NAME="Heading7"></A><FONT COLOR="#000077">Following a Print Request</FONT></H4>
<P>To understand how the print daemon works, as well as how print requests are managed by Linux, it is instructive to follow a print request. When a user requests a print job with the <TT>lpr</TT> command, <TT>lpr</TT> assembles the data to be printed and copies it into the spooling queue, where <TT>lpd</TT> can find it.</P>
<BLOCKQUOTE>
<P><FONT SIZE="-1"><HR><B>Note: </B><BR>The <TT>lpr</TT> program is the only one in the Linux system that can actually queue files for printing. Any other program that offers printing capabilities does so by calling <TT>lpr</TT>.<HR></FONT>
</BLOCKQUOTE>
<P>As part of its spooling task, <TT>lpr</TT> also checks for instructions on how to print the file. It can get the information from three sources: the command line (supplied as arguments), environment variables (set by the shell or the user), or the system’s default values.</P>
<P>The <TT>lpr</TT> program knows which spool to put the print request in because of the destination printer designation. The printer destination can be specified on the <TT>lpr</TT> command line or through an environment variable. When the destination printer name has been determined, <TT>lpr</TT> checks the file <TT>/etc/printcap</TT> to look up the printer’s information, including the spool directory. The spool directory is usually of the form <TT>/usr/spool/printer_name</TT>, such as <TT>/usr/spool/lp1</TT>.</P>
<P>Within the spool directory, <TT>lpr</TT> creates two files. The first has the letters <TT>cf</TT> (control file) followed by a print ID number. The <TT>cf</TT> file contains information about the print job, including the owner’s name. The second file starts with <TT>df</TT> (data file) and has the actual contents of the file to be printed with it. When <TT>lpr</TT> has finished creating the <TT>df</TT> file, it sends a signal to <TT>lpd</TT> that informs the daemon that a print job is waiting in the spool directory.</P>
<P>When <TT>lpd</TT> gets the signal from <TT>lpr</TT>, it checks the file <TT>/etc/printcap</TT> to see whether the printer is for a local or remote printer. If the print job is for a remote printer (one attached to another machine on the network), <TT>lpd</TT> opens a connection to the remote machine, transfers both the control and data files, and deletes the local copies.</P>
<P>If the print job is for a local printer, <TT>lpd</TT> checks to make sure the printer exists and is active, and then sends the print request to the printing daemon running that queue.</P><P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="583-586.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="589-591.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
</td>
</tr>
</table>
<!-- begin footer information -->
</body></html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?