Home » Linux Basics » 03 - Basic Commands
3

Printer Control

Storing list of commands and adding a document to a print queue

The lpr command (line printer) adds a document to a print queue. As the printer completes printing other documents, a document on the queue keeps moving up until it gets to the top of the queue. The /etc/printcap file contains details on available printers. The lpr command sends a document to the printer as it is. The document is sent in raw form. If it is of a specific non-text format, only garbage comes out unless it is converted to PostScript and sent to a PostScript printer.

    lpr -P<print_queue> <file_name>

The basic syntax just sends the specified document to a general printer; the -P or -d option may be used to specify a printer - 'lpr -d printer_reference file_name' or 'lpr -P printer_reference file_name'.

Users may utilize the lpq command to find the position of their job on the print queue. This command also displays information about the current status of the queue - whether jobs are getting processed, the printer has stopped and so on. Each print job has an associated job number that may be used to remove the job from the queue.

    lpq -P<print_queue> 

The lprm command deletes items from the print queue. The item's job number should be passed into the command as an argument.

    lprm -P<print_queue> <job_number> 

lpr, lpq and lprm are BSD-style print management utilities. Some distributions use parallel commands lp, lpstat, and cancel.