previous contents up next

Unix for Advanced Users

17. Light Sysadmin Tasks

17.4 Printer Administration

The administration of printers in a Unix environment is a complicated topic, taken as a whole. This is mainly due to the many possible hardware and network configuration scenarios. There are three basic options for attaching a Unix workstation or server to a printer: through the serial port, the parallel port or as a network device. Although possible, serial printers are rarely used today. This is due, largely, to the poor performance of serial throughput, compared to a parallel connection or a network interface. This section will not describe serial printer configuration.

There are two spooling subsystems in common use with Unix operating systems, the Berkeley (BSD) and System V systems. The IBM AIX operating system has a generic queuing system, used by the printing subsystem, which will not be described here. AIX does support both the BSD and System V user print commands: lpr, lpq, lprm and lp, lpstat, cancel, as do several commercial Unix variants today.

BSD Printing System

The BSD printing system is the simpler of the two systems discussed here. It is composed of five programs, one configuration file and spooling directories for each print queue. These components of the BSD system are:

lpr
Adds a print job to a specified (or default) queue. By default, the file to be printed is physically copied to the spool area, although an option to use symbolic links is available on some systems.
If the queue is not specified with the -Pqueue option, the default queue is specified by the PRINTER environment variable or the lp queue, if PRINTER is undefined.
Sample usage: % lpr -Pwrubel_109 foo.txt
lpq
Lists print jobs in the specified queue.
Sample usage: % lpq -Pwrubel_109
lprm
Removes jobs, based on specified job id values. A user may only remove his or her own print jobs, but not those of other users. The superuser, as you might suspect, may remove any or all print jobs currently queued.
Sample usage: % lprm -Pwrubel_109 42
lpd
The BSD printer daemon. This program runs continuously (in normal operation), spooling print requests from queues to their respectively defined printers. This program uses the /etc/printcap file to configure itself.
lpc
The administrator's interface to the BSD print system. This is an interactive facility, from which the sysadmin may start, stop, restart or clear print queues.
Sample usage: % lpc status
or
% lpc
lpc> status
/etc/printcap
The BSD printer configuration file. This file is formatted like the termcap database, but is required for the printing subsystem to function.
Sample printcap entry:
wrubel_109|lp|Wrubel 109 Printer:\
:rm=wcc109.iu.edu:\
:rp=raw:\
:lf=/var/adm/printlogs/wrubel_109.log:\
:sd=/var/spool/wrubel_109:

Light system administration tasks with BSD printing would include starting, stopping, clearing and restarting queues. A quick description of defining a printer in the /etc/printcap file will be given below, spotlighting the more important printcap tags:

lp
The name of the printer device, typically found in /dev/: e.g. :lp=/dev/lp:. This would be used for a local printer.
rm
The Internet name of a remote host or printer, to which print jobs sent to this queue should be sent. This would be used for a remote printer, and must be accompanied by an rp tag: e.g. :rm=foo.bar.edu:.
rp
The name of the queue on the remote host, specified by an rm tag, to which the remotely spooled print job should be submitted: e.g. :rp=fooqueue:.
lf
The filename to which error reports should be appended: e.g. :lf=/var/adm/printlogs/wrubel_109.log:.
sd
The spooling directory, or the directory in which files requested for printing on this queue are copied, while waiting to be sent to the printer or remote queue: e.g. :sd=/var/spool/wrubel_109:.

The printcap tags described above are the minimal set needed to specify a print queue with the BSD spooler. The first line of the printcap entry:

wrubel_109|lp|Wrubel 109 Printer:\
indicates a queue name, wcclp, an alias, lp, and an optional description, "Wrubel 109 Printer". The alias lp is special, as it defines the default printer, or the queue to which jobs are sent when no queue is specified on the lpr command line. The use of the rm tag indicates that the queue is defined either for a printer on another machine, which may take remote requests for printing, or for a printer designed to live on the network by itself (e.g. an HP LaserJet print server with JetDirect option).

After defining a printcap entry, and before attempting to fire up the queue, you must create the spooling directory. The directory must be owned by the user daemon and group daemon, with permissions 755 (or rwxr-xr-x). This forces a user to go through the BSD interface to print or modify any print jobs, and avoids unwanted "help" from users who feel that other users' print jobs might be bogging down the efficiency of their own printing progress.   :^)

To start you're new print queue, assuming the name wcclp, run:

# lpc enable wcclp
# lpc start wcclp
or
# lpc up wcclp (does both of the above commands)
and
# lpc status
The first command enables queuing on the new queue. The second command starts the queue, such that queued requests will begin printing. The third command allows the first two commands may be lumped together in a single command, which is convenient.The fourth command shows the status of all defined print queues. To bring a queue down and/or simply disable queuing, the following commands are used:
# lpc stop wcclp
# lpc disable wcclp
or
# lpc down wcclp (does both of the above commands)

System V Printing System

The System V printing system is considerably more flexible than the BSD system. The same BSD functionality exists for this printing system, with additional allowances for printer "classes", where printers may be grouped on a single queue, dynamic re-queuing of print requests to other queues and access control lists. However, with the addition of such flexibility, the number of commands and options per command for management of the print system goes up dramatically over the BSD system. Therefore, this section will discuss the user commands for System V printing, but recommend the use of the system management interfaces (graphical or terminal-based), which are bundled with every commercial Unix brand (e.g. HP-UX's SAM), for print system management. If you are interested in the command line interface to managing the System V print system, we recommend the O'Reilly book "Essential System Administration, 2nd Edition" by Aeleen Frisch as a very readable (and affordable) reference.

The user interface to System V printing is analogous to the BSD system. (Un)fortunately, some systems have incorporated the two systems, notably HP-UX, which allows for both BSD and System V style interfaces that spool under a System V spooler. While this is very convenient, especially to older codes/scripts that rely on BSD printing, it can be confusing to the user as to what is actually going on. However, we will punt this issue (as there is no "solution") and direct you to your system administrator for details on the exact nature of how print serving is done on your Unix platform.

lp   (analogous to lpr)
Adds a print job to a specified (or default) queue. By default, the file to be printed is linked in the spool area, although an option to copy the file to the spool area is generally available. Note that this is exactly opposite the default behavior of the BSD lpr command. It means you had better not modify or delete the file you choose to print, until it's printed (or specify the option to copy).
If the queue is not specified with the -dqueue option, the default queue is specified by the LPDEST environment variable or the system default, if LPDEST is undefined.
Sample usage: % lp -dwrubel_109 foo.txt
lpstat   (analogous to lpq)
List print requests in the specified queue. (In System V, they're "requests".)
Sample usage: % lpstat wrubel_109
List all defined queues: % lpstat -t
cancel   (analogous to lprm)
Removes requests, based on specified job id values. A user may only remove his or her own print jobs, but not those of other users. The superuser, may remove any or all print jobs currently queued.
Sample usage: % cancel wrubel_109-42
Cancel all authorized jobs in queue: % cancel -a wrubel_109
lpmove
A sysadmin-only command to move requests from one queue to another.
Usage 1 allows a list of requests to be requeued. Usage 2 allows all requests on the first queue rescheduled on the second.
Usage 1: # lpmove slowpoke-10,laser-209 mama
Usage 2: # lpmove slowpoke mama
enable and disable
Like the lpc start and lpc stop BSD commands, these sysadmin-only commands allow you to start and stop printing queued requests.
See below for sample usage, with accept and reject.
accept and reject
Like the lpc enable and lpc disable BSD commands (note confusion here), these sysadmin-only commands allow you to start and stop queuing on a particular queue.
Sample scenario: Stop "slowpoke" and it's queue. Send its queued requests to "mama":
# disable slowpoke
# reject slowpoke
# accept mama
# lpmove slowpoke mama
# enable mama

previous contents up next