586 588




Linux Unleashed, Third Edition:Devices





-->















Previous
Table of Contents
Next




The mknod Command
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 command is


mknod [options] device b|c|p|u major minor


The options can be one of the following:


--help displays help information and then exits.
-m [mode] sets the mode of the file to mode instead of the default 0666 (only sym-
bolic notation is allowed).
--version displays version information, then exits.

The argument after the device or pathname specifies whether the file is a block mode device (b), character mode device (c), FIFO device (p), or unbuffered character mode device (u). One of these arguments must be present on the command line.
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.
Examples of using the mknod command are shown in several sections later in this chapter, when devices are added to the system.
Printer Administration
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.

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!
The lpd Printing Daemon
All printing on the Linux system is handled by the lpd daemon, which is usually started when the system boots. During the startup process, the lpd daemon reads through the file /etc/printcap to identify the sections that apply to any of the printers known to be attached to the system. The lpd daemon uses two other processes, called listen and accept, to handle incoming requests for printing and to copy them to a spooling area.
In most cases, you won’t have to modify the lpd daemon. However, there might be times when you have to stop it manually and restart it. The command to load lpd is


lpd [-l] [port]


The -l 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 lpd 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.
The size of the print spool area is set by an entry in the file minfree in each spool directory (each printer has its own spool directory). The contents of minfree 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.
Access to the lpd daemon to allow printing of a user request must pass a quick validation routine. Two files are involved: /etc/hosts.equiv and /etc/hosts.lpd. 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 hosts.equiv (as localhost), users on the Linux machine should always have their print requests granted.
Following a Print Request
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 lpr command, lpr assembles the data to be printed and copies it into the spooling queue, where lpd can find it.

Note:  The lpr 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 lpr.

As part of its spooling task, lpr 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.
The lpr program knows which spool to put the print request in because of the destination printer designation. The printer destination can be specified on the lpr command line or through an environment variable. When the destination printer name has been determined, lpr checks the file /etc/printcap to look up the printer’s information, including the spool directory. The spool directory is usually of the form /usr/spool/printer_name, such as /usr/spool/lp1.
Within the spool directory, lpr creates two files. The first has the letters cf (control file) followed by a print ID number. The cf file contains information about the print job, including the owner’s name. The second file starts with df (data file) and has the actual contents of the file to be printed with it. When lpr has finished creating the df file, it sends a signal to lpd that informs the daemon that a print job is waiting in the spool directory.
When lpd gets the signal from lpr, it checks the file /etc/printcap 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), lpd opens a connection to the remote machine, transfers both the control and data files, and deletes the local copies.
If the print job is for a local printer, lpd checks to make sure the printer exists and is active, and then sends the print request to the printing daemon running that queue.



Previous
Table of Contents
Next














Wyszukiwarka

Podobne podstrony:
588 angkonwersacjeprzedstf
585 588
584 588
586 589
README (588)

więcej podobnych podstron