Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Linux+ Certification Bible.pdf
Скачиваний:
46
Добавлен:
15.03.2015
Размер:
3.78 Mб
Скачать

364 Part IV Administration

Configuring Linux Printing

4.15 Manage print spools and queues

Printing is one of the most important user functions on a Linux system. Consequently, it is also one of the biggest contributors when it comes to day-to-day problems. Although each Linux distribution has its own method for setting up printers, they are usually based on the original Unix printing facility, which is the lpd daemon.

lpd daemon

Line Printer Daemon, or lpd, refers to the entire collection of programs that deal with print spooling. The lpd daemon is run when the Linux system first boots. The first operation that it performs is reading the configuration from the /etc/printcap file, which defines the printers that it will spool for. It then runs two programs, listen and accept, which wait for and accept user requests to print.

When the lpd daemon receives a request, the pages to be printed are copied to a different area on disk, which is the spool directory, usually located in /var/spool. This process frees up the current console shell after sending a print request.

The spool directory contains a file for every printer that is connected, either directly or remotely, to the system. When a print request is received for that printer, two files are created: A control file with the extension .cf, and a print file that is identified by a print ID number with a .df extension. The control file sends parameters to the printer, including information about the print job, such as the user’s name and the name of the file. The data file contains the actual print job.

The lpd daemon then starts a process for that printer, which will begin queuing the file to the actual printer. After the job finishes, the files are deleted from the spool directory. When the print queue is empty, the daemon terminates.

/etc/printcap

The file /etc/printcap contains information about every printer (local or remote) that is connected to the Linux system. The lpd daemon and lpr command use this file to determine the type of characteristics for the printer. The following is a sample /etc/printcap file for an HP Laserjet printer:

# HP Laserjet lp|hplj|hplaserjet|HP LaserJet4M:\ :lp=/dev/lp0:\ :sd=/var/spool/lp/lp0:\ :lf=/var/spool/lp/errorlog:\ :mx#0:\ :of=/var/spool/lp0/hpjlp:\

Chapter 11 Linux System Commands 365

The second line refers to the different names with which the users can refer to the printer when they are configuring their machine for printing. The other variables in the configuration file include:

lp: The device name of the printer

sd: The spool directory

lf: The log directory for error messages

af: Accounting log file

mx: What type of files can be printed

of: Output filter program to be used when printing

Printing management

The administrator can use several commands to manage and use print queues and spooling. Each command has a variety of options to help maintain your printing environment.

lpc

The line printer control (lpc) command is used to control the operation of the line printer system. For each printer configured in /etc/printcap, the lpc command can perform a variety of functions:

lpc abort: Immediately terminates an active spooling daemon on the local host and then disables printing (preventing new daemons from being started by lpr) for the specified printers.

lpc clean: Removes any temporary files, data files, or control files that can’t be printed from the specified printer queue on the local machine.

lpc disable: Turns the specified printer queues off. This prevents lpr from entering new printer jobs into the queue.

lpc enable: Enables spooling on the local queue for the listed printers. This allows lpr to put new jobs in the spool queue.

lpc up: Enables the print queues and starts a new printer daemon; also undoes the effects of the lpc down command.

lpc down: Turns the specified printer queue off, disables printing and puts a message in the printer status file. The message doesn’t need to be quoted — the remaining arguments are treated like echo. lpq indicates that the printer is down and prints the status message.

lpc exit/quit: Exits from lpc.

Соседние файлы в предмете Операционные системы