rhl38.htm

来自「linux的初学电子书」· HTM 代码 · 共 2,175 行 · 第 1/5 页

HTM
2,175
字号
<HTML>

<HEAD>

<TITLE>Red Hat Linux Unleashed rhl38.htm </TITLE>

<LINK REL="ToC" HREF="index-1.htm" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/index.htm">

<LINK REL="Index" HREF="htindex.htm" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/htindex.htm">

<LINK REL="Next" HREF="rhl39.htm" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/rhl39.htm">

<LINK REL="Previous" HREF="rhl37.htm" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/rhl37.htm"></HEAD>

<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#800080">

<A NAME="I0"></A>

<H2>Red Hat Linux Unleashed rhl38.htm</H2>

<P ALIGN=LEFT>

<A HREF="rhl37.htm" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/rhl37.htm" TARGET="_self"><IMG SRC="purprev.gif" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/purprev.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="Previous Page"></A>

<A HREF="index-1.htm" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/index.htm" TARGET="_self"><IMG SRC="purtoc.gif" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/purtoc.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="TOC"></A>

<A HREF="rhl39.htm" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/rhl39.htm" TARGET="_self"><IMG SRC="purnext.gif" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/purnext.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="Next Page"></A>


<HR ALIGN=CENTER>

<P>

<UL>

<UL>

<UL>

<LI>

<A HREF="#E68E327" >Character and Block Mode Devices</A>

<UL>

<LI>

<A HREF="#E69E425" >Major and Minor Device Numbers</A>

<LI>

<A HREF="#E69E426" >The mknod Command</A></UL>

<LI>

<A HREF="#E68E328" >Printer Administration</A>

<UL>

<LI>

<A HREF="#E69E427" >The lpd Printing Daemon</A>

<LI>

<A HREF="#E69E428" >Following a Print Request</A>

<LI>

<A HREF="#E69E429" >The /etc/printcap File and Spooling Directories</A>

<LI>

<A HREF="#E69E430" >Adding Printer Devices with mknod</A>

<LI>

<A HREF="#E69E431" >Managing Printers with lpc</A>

<LI>

<A HREF="#E69E432" >Managing the Printer Queue with lpq and lprm</A></UL>

<LI>

<A HREF="#E68E329" >Terminals</A>

<UL>

<LI>

<A HREF="#E69E433" >Using Multiport Cards</A>

<LI>

<A HREF="#E69E434" >Adding Serial Port Terminals</A>

<LI>

<A HREF="#E69E435" >The Login Process</A>

<LI>

<A HREF="#E69E436" >What Are /sbin/getty and /etc/gettydefs?</A>

<LI>

<A HREF="#E69E437" >Terminal Files /etc/ttys and /etc/inittab</A>

<LI>

<A HREF="#E69E438" >Terminal Definitions The /etc/termcap File</A>

<LI>

<A HREF="#E69E439" >Adding a Terminal</A>

<LI>

<A HREF="#E69E440" >Using stty and tset</A>

<LI>

<A HREF="#E69E441" >Resetting a Screwy Terminal</A></UL>

<LI>

<A HREF="#E68E330" >Adding a Modem</A>

<LI>

<A HREF="#E68E331" >Summary</A></UL></UL></UL>

<HR ALIGN=CENTER>

<A NAME="E66E38"></A>

<H1 ALIGN=CENTER>

<CENTER>

<FONT SIZE=6 COLOR="#FF0000"><B>38</B></FONT></CENTER></H1>

<BR>

<A NAME="E67E38"></A>

<H2 ALIGN=CENTER>

<CENTER>

<FONT SIZE=6 COLOR="#FF0000"><B>Devices and Device Administration</B></FONT></CENTER></H2>

<BR>

<P>This chapter is devoted to devices that might be attached to your Linux system, such as terminals, modems, and printers. It shows you how to add and manage the different devices, and it also looks at many of the Linux commands you will need to properly 
administer your system.

<BR>

<P>In this chapter, you will learn the following:

<BR>

<UL>

<LI>What a device driver is

<BR>

<BR>

<LI>The difference between block mode and character mode devices

<BR>

<BR>

<LI>Major and minor device numbers

<BR>

<BR>

<LI>The mknod command

<BR>

<BR>

<LI>How to manage printers and the print spooler

<BR>

<BR>

<LI>How to add a printer

<BR>

<BR>

<LI>How to add a terminal and modem

<BR>

<BR>

<LI>The configuration files used by terminals

<BR>

<BR>

<LI>The startup sequence used to permit logins

<BR>

<BR>

</UL>

<P>All of this information is necessary if you are to have a smoothly running system. Even if you don't intend to add terminals or modems, you should know about the startup process and how the configuration files are handled.

<BR>

<BR>

<A NAME="E68E327"></A>

<H3 ALIGN=CENTER>

<CENTER>

<FONT SIZE=5 COLOR="#FF0000"><B>Character and Block Mode Devices</B></FONT></CENTER></H3>

<BR>

<P>Everything attached to the computer you are using to run Linux is treated as a device by the operating system. It doesn't matter whether the device is a terminal, a hard disk, a printer, a CD-ROM drive, or a modem. Everything that accepts or sends data 
to the operating system is a device.

<BR>

<P>The concept of treating everything on the system as a device is one of the benefits of the UNIX architecture. Each device has a special section in the kernel, called a device driver, which includes all the instructions necessary for Linux to communicate 
with the device. When a new device is developed, it can be used with Linux by writing a device driver, which is usually a set of instructions that explains how to send and receive data.

<BR>

<P>Device drivers allow the Linux kernel to include only the operating system and support software. By having the instructions for talking to devices within a set of files, they can be loaded as needed (in the case of rarely used devices), or kept in 
memory all the time when the operating system boots. As refinements are made to a peripheral, small changes to the device driver file can be linked into the kernel to keep the operating system informed of the new features and capabilities.

<BR>

<P>When an application instructs a device to perform an action, the Linux kernel doesn't have to worry about the mechanism. It simply passes the request to the device driver and lets it handle the communications. Similarly, when you're typing at the 
keyboard, your terminal's device driver accepts the keystrokes and passes them to the shell or application, filtering out any special codes that the kernel doesn't know how to handle by translating them into something the kernel can perform.

<BR>

<P>Linux keeps device files in the /dev directory by default and convention. It is permissible to keep device files anywhere on the file system, but keeping them all in /dev makes it obvious that they are device files.

<BR>

<P>Every type of device on the Linux system communicates in one of two ways: character by character or as a set of data in a predefined chunk or block. Terminals, printers, and asynchronous modems are character devices, using characters sent one at a time 
and echoed by the other end. Hard drives and most tape drives, on the other hand, use blocks of data, because this is the fastest way to send large chunks of information. These peripherals are called either character mode or block mode devices, based on 
the way they communicate.

<BR>

<BLOCKQUOTE>

<BLOCKQUOTE>

<HR ALIGN=CENTER>

<BR>

<NOTE>Another way to differentiate between character and block mode devices is by how the buffering to the device is handled. Character mode devices want to do their own buffering. Block mode devices, which usually communicate in chunks of 512 or 1,024 
bytes, have the kernel perform the buffering.

<BR>Some devices can be both character and block mode devices. Some tape drives, for example, can handle both character and block modes, and therefore have two different device drivers. The device driver that is used depends on how the user wants to write 
data to the device.</NOTE>

<BR>

<HR ALIGN=CENTER>

</BLOCKQUOTE></BLOCKQUOTE>

<P>The device file has all the details about whether the device is a character mode or block mode device. There is an easy way to tell which type of device a peripheral is: Look at the output of the listing command that shows file permissions (such as ls 
-l). If the first character is a b, the device is a block mode device; a c indicates a character mode device.

<BR>

<P>Device files are usually named to indicate the type of device they are. Most terminals, for example, have a device driver with the name tty followed by two or more letters or numbers, such as tty1, tty1A, or tty04. The letters tty identify the file as a 
terminal (tty stands for teletype), and the numbers or letters identify the specific terminal referred to. When coupled with the directory name /dev, the full device driver name becomes /dev/tty01.

<BR>

<BR>

<A NAME="E69E425"></A>

<H4 ALIGN=CENTER>

<CENTER>

<FONT SIZE=4 COLOR="#FF0000"><B>Major and Minor Device Numbers</B></FONT></CENTER></H4>

<BR>

<P>There might be more than one device of the same type on a system. For example, your Linux system might have a multiport card (multiple serial ports) with 10 Wyse 60 terminals hanging off it. Linux can use the same device driver for each of the terminals 
because they are all the same type of device.

<BR>

<P>However, there must be a method for the operating system to differentiate which one of the 10 terminals you want to address. That's where device numbers are used. Each device is identified by two device numbers: The major number identifies the device 
driver to be used, and the minor number identifies the device number. For example, the 10 Wyse 60 terminals on the multiport card can all use a device file with the same major number, but each will have a different minor number, thereby uniquely 
identifying it to the operating system.

<BR>

<P>Every device on the system has both major and minor device numbers assigned in such a way as to ensure that they are unique. If two devices are assigned the same number, Linux can't properly communicate with them.

<BR>

<P>Some devices use the major and minor device numbers in a strange way. Some tape drives, for example, use the minor number to identify the density of the tape and adjust its output in that manner.

<BR>

<P>Device files are created with the command mknod (make node) and removed with the standard rm command.

<BR>

<BR>

<A NAME="E69E426"></A>

<H4 ALIGN=CENTER>

<CENTER>

<FONT SIZE=4 COLOR="#FF0000"><B>The </B><B>mknod</B><B> Command</B></FONT></CENTER></H4>

<BR>

<P>The mknod (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 com-mand is

<BR>

<BR>

<PRE>

<FONT COLOR="#000080">mknod [options] device b|c|p|u major minor</FONT></PRE>

<P>The options can be one of the following:

<BR>



<TABLE  BORDERCOLOR=#000040 BORDER=1 CELLSPACING=2 WIDTH="100%" CELLPADDING=2 >

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

&#151;help

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

displays help information and then exits.</FONT>

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

-m [mode]

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

sets the mode of the file to mode instead of the default 0666 (only symbolic notation is allowed).</FONT>

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

&#151;version

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

displays version information, then exits.</FONT>

</TABLE><P>The argument after the device or pathname specifies whether the file is a block mode device , character mode device , FIFO device (p), or unbuffered character mode device (u). One of these arguments must be present on the command line.

<BR>

<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 p device.

<BR>

<P>Examples of using the mknod command are shown in several sections later in this chapter, when devices are added to the system.

<BR>

<BR>

<A NAME="E68E328"></A>

<H3 ALIGN=CENTER>

<CENTER>

<FONT SIZE=5 COLOR="#FF0000"><B>Printer Administration</B></FONT></CENTER></H3>

<BR>

<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.

<BR>

<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!

<BR>

<BR>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?