9.5 Using PrintersThis section tells you how to use printers you have set up with FreeBSD. Here is an overview of the user-level commands: There is also an administrative command, lpc(8), described in the section Administering the LPD Spooler, used to control printers and their queues. All three of the commands lpr(1), lprm(1), and lpq(1) accept an
option Hereafter, the terminology default printer means the printer named in the PRINTER environment variable, or the printer named lp when there is no PRINTER environment variable. 9.5.1 Printing JobsTo print files, type: % lpr filename ... This prints each of the listed files to the default printer. If you list no files, lpr(1) reads data to print from standard input. For example, this command prints some important system files: % lpr /etc/host.conf /etc/hosts.equiv To select a specific printer, type: % lpr -P printer-name filename ... This example prints a long listing of the current directory to the printer named rattan: % ls -l | lpr -P rattan Because no files were listed for the lpr(1) command, lpr read the data to print from standard input, which was the output of the ls -l command. The lpr(1) command can also accept a wide variety of options to control formatting, apply file conversions, generate multiple copies, and so forth. For more information, see the section Printing Options. 9.5.2 Checking JobsWhen you print with lpr(1), the data you wish to print is put together in a package called a “print job”, which is sent to the LPD spooling system. Each printer has a queue of jobs, and your job waits in that queue along with other jobs from yourself and from other users. The printer prints those jobs in a first-come, first-served order. To display the queue for the default printer, type lpq(1). For a specific
printer, use the % lpq -P bambooshows the queue for the printer named bamboo. Here is an example of the output of the lpq command: bamboo is ready and printing Rank Owner Job Files Total Size active kelly 9 /etc/host.conf, /etc/hosts.equiv 88 bytes 2nd kelly 10 (standard input) 1635 bytes 3rd mary 11 ... 78519 bytes This shows three jobs in the queue for bamboo. The first job, submitted by user kelly, got assigned “job number” 9. Every job for a printer gets a unique job number. Most of the time you can ignore the job number, but you will need it if you want to cancel the job; see section Removing Jobs for details. Job number nine consists of two files; multiple files given on the lpr(1) command line are treated as part of a single job. It is the currently active job (note the word active under the “Rank” column), which means the printer should be currently printing that job. The second job consists of data passed as the standard input to the lpr(1) command. The third job came from user mary; it is a much larger job. The pathname of the file she is trying to print is too long to fit, so the lpq(1) command just shows three dots. The very first line of the output from lpq(1) is also useful: it tells what the printer is currently doing (or at least what LPD thinks the printer is doing). The lpq(1) command also
support a
waiting for bamboo to become ready (offline ?)
kelly: 1st [job 009rose]
/etc/host.conf 73 bytes
/etc/hosts.equiv 15 bytes
kelly: 2nd [job 010rose]
(standard input) 1635 bytes
mary: 3rd [job 011rose]
/home/orchid/mary/research/venus/alpha-regio/mapping 78519 bytes
9.5.3 Removing JobsIf you change your mind about printing a job, you can remove the job from the queue with the lprm(1) command. Often, you can even use lprm(1) to remove an active job, but some or all of the job might still get printed. To remove a job from the default printer, first use lpq(1) to find the job number. Then type: % lprm job-number To remove the job from a specific printer, add the % lprm -P bamboo 10 The lprm(1) command has a few shortcuts:
Just use the % lprm -P rattan -
9.5.4 Beyond Plain Text: Printing OptionsThe lpr(1) command supports a number of options that control formatting text, converting graphic and other file formats, producing multiple copies, handling of the job, and more. This section describes the options. 9.5.4.1 Formatting and Conversion OptionsThe following lpr(1) options control formatting of the files in the job. Use these options if the job does not contain plain text or if you want plain text formatted through the pr(1) utility. For example, the following command prints a DVI file (from the TeX typesetting system) named fish-report.dvi to the printer named bamboo: % lpr -P bamboo -d fish-report.dvi These options apply to every file in the job, so you cannot mix (say) DVI and ditroff files together in a job. Instead, submit the files as separate jobs, using a different conversion option for each job.
Here is an example: this command prints a nicely formatted version of the ls(1) manual page on the default printer: % zcat /usr/share/man/man1/ls.1.gz | troff -t -man | lpr -t The zcat(1) command
uncompresses the source of the ls(1) manual page and
passes it to the troff(1) command,
which formats that source and makes GNU troff output and passes it to lpr(1), which submits
the job to the LPD spooler. Because we used the 9.5.4.2 Job Handling OptionsThe following options to lpr(1) tell LPD to handle the job specially:
9.5.4.3 Header Page OptionsThese options to lpr(1) adjust the text that normally appears on a job's header page. If header pages are suppressed for the destination printer, these options have no effect. See section Header Pages for information about setting up header pages.
9.5.5 Administering PrintersAs an administrator for your printers, you have had to install, set up, and test them. Using the lpc(8) command, you can interact with your printers in yet more ways. With lpc(8), you can
First, a note about terminology: if a printer is stopped, it will not print anything in its queue. Users can still submit jobs, which will wait in the queue until the printer is started or the queue is cleared. If a queue is disabled, no user (except root) can submit jobs for the printer. An enabled queue allows jobs to be submitted. A printer can be started for a disabled queue, in which case it will continue to print jobs in the queue until the queue is empty. In general, you have to have root privileges to use the lpc(8) command. Ordinary users can use the lpc(8) command to get printer status and to restart a hung printer only. Here is a summary of the lpc(8) commands. Most of the commands take a printer-name argument to tell on which printer to operate. You can use all for the printer-name to mean all printers listed in /etc/printcap.
lpc(8) accepts the above commands on the command line. If you do not enter any commands, lpc(8) enters an interactive mode, where you can enter commands until you type exit, quit, or end-of-file. This, and other documents, can be downloaded from ftp://ftp.FreeBSD.org/pub/FreeBSD/doc/. For questions about FreeBSD, read the documentation before contacting <questions@FreeBSD.org>. |