lpr
Print files to a printer
TLDR
Print a file to the default printer
Print 2 copies
Print to a named printer
Print either a single page (e.g. 2) or a range of pages (e.g. 2-16)
Print double-sided either in portrait (long) or in landscape (short)
Set page size (more options may be available depending on setup)
Print multiple pages per sheet
SYNOPSIS
lpr [options] [file...]
PARAMETERS
-P destination
Specifies the destination printer or queue name. If not specified, the default printer is used.
-# copies
Specifies the number of copies to print.
-C class
Sets the job classification name. Mostly relevant to accounting purposes.
-J job
Sets the job name.
-m
Sends mail after the job has been printed.
-r
Removes the file after submitting it for printing.
-s
Uses symbolic links instead of copying files to the spool directory. This is only useful if the file to be printed is kept in place after printing is done.
-l
Print control characters literally and suppress page breaks.
-d
When used with -l, treats the data stream as DVI (DeVice Independent) format.
-p
Use pr(1) to format the files before printing.
DESCRIPTION
The lpr command is a command line utility in Unix-like operating systems used for printing files. It submits print jobs to the spooling daemon (typically CUPS or a similar printing system) for printing. lpr doesn't directly send output to the printer, instead, it spools the jobs which are then handled by the print daemon. This allows users to continue working without waiting for the print job to complete. By default, lpr prints to the system's default printer, but you can specify a different printer using the -P option. It accepts various file types, interpreting them according to the configured print system. lpr handles the print queue and manages the order in which print jobs are processed. Modern implementations often use CUPS (Common Unix Printing System) as the underlying printing system.
FILE TYPES
lpr, in conjunction with the print spooler (like CUPS), attempts to determine the file type automatically. Configuration files within the print system map file extensions to filter rules to convert a file to a printable format. Problems can arise with unusual file types or when automatic detection fails. Specify appropriate filters in your printing system for the best results.
In case of uninterpretable files, try using 'pr' command to format the file for printing first using option '-p'.
TROUBLESHOOTING
If print jobs are not appearing, check the print queue using 'lpq' or CUPS web interface to ensure the job was submitted. Verify the printer is online and configured correctly in the printing system. Look for error messages in the CUPS error log to diagnose issues.
HISTORY
The lpr command has its roots in the early days of Unix, dating back to the 1970s. It was initially designed to provide a simple interface for submitting print jobs to line printers.
Over time, as printing technology evolved, the lpr command has been adapted and extended to support different printing systems. Modern implementations, like those using CUPS, provide a more sophisticated and flexible printing architecture, but the basic functionality of lpr remains the same: to submit files for printing.
The command has been a consistent part of the Unix and Linux landscape, maintaining backward compatibility while integrating with newer printing technologies.