The lpr command submits files for printing. Files supplied at the command-line are sent to the specified printer or to the print queue if the printer is busy. Without specifying the printer to use, the command will send the print job to the default printer, which you can configure with CUPS. The lpr command reads the print file from standard input if no files are supplied at the command-line.
Syntax
The syntax of the lpr command is:
# lpr [options] [file names]
lpr Command Options
The lpr command options are described in the following table.
Option | Description |
---|---|
-E | Force encryption when connecting to the server. |
-P {destination} | Send the print job to the destination printer specified. |
-# {copies} | Set the number of copies to print from 1 to 100. |
-T {name} | Set the job name. |
-l | Specify that the print file is already formatted and should be sent to the destination without being filtered. |
-o {option} | Set a job option, like printing in landscape mode, scaling the printed output, printing double-sided, etc. Job options vary depending on the printer. |
-p | Print the specified files with a shaded header that includes the date, time, job name, and page number. |
-r | Specify that the printed files should be deleted after printing. |
If you encounter the below error while running the lpr command:
lpr: command not found
you may try installing the below package as per your choice of distribution:
OS Distribution | Command |
---|---|
Debian | apt-get install lpr |
Ubuntu | apt-get install lpr |
Arch Linux | pacman -S lpr |
Kali Linux | apt-get install lpr |
CentOS | yum install lpr |
Raspbian | apt-get install lpr |
lpr Command Examples
1. Print a file to the default printer:
# lpr path/to/file
2. Print 2 copies:
# lpr -# 2 path/to/file
3. Print to a named printer:
# lpr -P printer path/to/file
4. Print either a single page (e.g. 2) or a range of pages (e.g. 2–16):
# lpr -o page-ranges=2|2-16 path/to/file
5. Print double-sided either in portrait (long) or in landscape (short):
# lpr -o sides=two-sided-long-edge|two-sided-short-edge path/to/file
6. Set page size (more options may be available depending on setup):
# lpr -o media=a4|letter|legal path/to/file
7. Print multiple pages per sheet:
# lpr -o number-up=2|4|6|9|16 path/to/file