591-593.html
来自「linux-unix130.linux.and.unix.ebooks130 l」· HTML 代码 · 共 115 行
HTML
115 行
<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=591-593//-->
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="589-591.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="593-594.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<H4 ALIGN="LEFT"><A NAME="Heading9"></A><FONT COLOR="#000077">Adding Printer Devices with mknod</FONT></H4>
<P>Linux supports both parallel and serial printer devices. Both parallel and serial printers are character mode devices. Unfortunately, most Linux distributions do not have an easy-to-use printer installation and configuration utilities like many UNIX versions. Instead, the printer devices must be created and set up manually.
</P>
<P>Parallel printers are referred to as devices <TT>lp0</TT>, <TT>lp1</TT>, or <TT>lp2</TT>, depending on the address of the parallel port they are used with. (The most common is the single parallel port on a PC, which is <TT>/dev/lp0</TT>.) Valid parallel port devices, their addresses, and their usual equivalents under MS-DOS are as follows:</P>
<CENTER>
<TABLE WIDTH="90%"><TR>
<TD WIDTH="20%"><TT>/dev/lp0</TT>
<TD WIDTH="20%"><TT>0x03bc</TT>
<TD WIDTH="60%">LPT1
<TR>
<TD><TT>/dev/lp1</TT>
<TD><TT>0x0378</TT>
<TD>LPT2
<TR>
<TD><TT>/dev/lp2</TT>
<TD><TT>0x0278</TT>
<TD>LPT3
</TABLE>
</CENTER>
<BLOCKQUOTE>
<P><FONT SIZE="-1"><HR><B>Note: </B><BR>To determine the address of a parallel port, you can use a diagnostic utility (such as DOS’s <TT>MSD.EXE</TT>). Some BIOS versions display port addresses when the system is booting. If you are unsure, try the ports starting with <TT>/dev/lp0</TT> and wait to see whether a printout is possible. The first parallel port on a PC is typically set to address <TT>0x03bc</TT>.<HR></FONT>
</BLOCKQUOTE>
<P>Linux uses the <TT>mknod</TT> (make node) command to create a parallel printer device file. After the device is made, the ownership of the device driver file must be altered to <TT>root</TT> or <TT>daemon</TT>.</P>
<P>The following is a command to make a parallel printer device on the first parallel port (<TT>/dev/lp0</TT>):</P>
<!-- CODE SNIP //-->
<PRE>
mknod -m 620 /dev/lp0 c 6 0
chown root.daemon /dev/lp0
</PRE>
<!-- END CODE SNIP //-->
<P>In this example, the file permissions are set to mode <TT>620</TT>, the device <TT>/dev/lp0</TT> is created, and it is set to be a character mode device with major device number of <TT>6</TT> and a minor device number of <TT>0</TT>. Usually, minor device numbers start at <TT>0</TT> and are incremented upward; therefore, because this is the first printer added, the minor device number is set to <TT>0</TT>.</P>
<BLOCKQUOTE>
<P><FONT SIZE="-1"><HR><B>Note: </B><BR>The ownership <TT>root.daemon</TT> is a special Linux convention for the daemons run by <TT>root</TT>. The entry <TT>root.daemon</TT> does not appear in the <TT>/etc/passwd</TT> file. This uses a convention that lets the first part of the entry (before the period) indicate the user and the second part (after the period) represent the group.<HR></FONT>
</BLOCKQUOTE>
<P>If a different device is configured, the device name itself must be changed to the device number. For each possible parallel port, the <TT>mknod</TT> commands are as follows:</P>
<!-- CODE SNIP //-->
<PRE>
mknod -m 620 /dev/lp0 c 6 0
mknod -m 620 /dev/lp1 c 6 1
mknod -m 620 /dev/lp2 c 6 2
</PRE>
<!-- END CODE SNIP //-->
<P>In these examples, the minor device numbers have been incremented to correspond to the port number. This is not necessary, but it can help with identification.
</P>
<P>After the <TT>mknod</TT> and <TT>chown</TT> commands have been issued, it is advisable to manually check to ensure that the ownerships are set properly and that a spool directory has been created. If the spool directory doesn’t exist, you have to create it manually. The permissions and ownership requirements of the spool directory were given earlier in the section “The <TT>/etc/printcap</TT> File and Spooling Directories.”</P>
<H4 ALIGN="LEFT"><A NAME="Heading10"></A><FONT COLOR="#000077">Managing Printers with lpc</FONT></H4>
<P>Printers are controlled through a utility called <TT>lpc</TT>. The <TT>lpc</TT> program lets you perform several important functions pertaining to the printers used on your Linux system:</P>
<DL>
<DD><B>•</B> Display printer status information
<DD><B>•</B> Enable or disable the printer
<DD><B>•</B> Enable or disable the printer queue
<DD><B>•</B> Remove all print requests from a printer’s queue
<DD><B>•</B> Promote a particular print request to the top of the queue
<DD><B>•</B> Make changes to the <TT>lpd</TT> printer daemon
</DL>
<P>The <TT>lpc</TT> program can’t be used for remote printers. It affects only those directly attached and configured on the local machine.</P>
<BLOCKQUOTE>
<P><FONT SIZE="-1"><HR><B>Warning: </B><BR>Be warned that <TT>lpc</TT> is one of the most unpredictable and unreliable programs included with the Linux operating system! It can hang up for no obvious reason, and it can also display erroneous status messages. In some cases, the only way to fix a severely screwed-up printer system is to reset the machine completely!<HR></FONT>
</BLOCKQUOTE>
<P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="589-591.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="593-594.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
</td>
</tr>
</table>
<!-- begin footer information -->
</body></html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?