Friday, December 23, 2011

lpr, lpq and lprm : Prints a File

The lpr (line printer) utility places one or more files in a print queue for printing. Linux provides print queues so that only one job is printed on a given printer at a time. A queue allows several people or jobs to send output simultaneously to a single printer with the expected results. On machines with access to more than one printer, you can use the –P option to instruct lpr to place the file in the queue for a specific printer, including one that is connected to another machine on the network. The following command prints the file named report:

$ lpr report


Because this command does not specify a printer, the output goes to the default printer, which is the printer when you have only one printer.

The next command line prints the same file on the printer named mailroom:

$ lpr -Pmailroom report


lpq - Queue of print jobs


You can see what jobs are in the print queue by using the lpq utility:

$ lpq

lp is ready and printing

Rank Owner Job Files Total Size

active alex 86 (standard input) 954061 bytes


In this example, Alex has one job that is being printed; no other jobs are in the queue.

lprm – Remove the items from print queue


You can use the job number (86 in this case) with the lprm utility to remove the job from the print queue and stop it from printing:

$ lprm 86


You can send more than one file to the printer with a single command. The following command line prints three files on the printer named laser1:

$ lpr -Plaser1 05.txt 108.txt 12.txt

No comments:

Post a Comment