Linux lp command
On Unix-like operating systems, the lp command prints files.
Description
lp submits files for printing, or alters a pending print job. Use a file name of "-" to specify printing from the standard input.
Default Destination
lp uses the common printing system CUPS, providing many ways to set the default destination. The LPDEST and PRINTER environment variables are checked first. If neither are set, the current default set using the lpoptions command is used, followed by the default set using the lpadmin command.
Syntax
lp -i request-ID [-c] [-m] [-p] [-s] [-w] [-d destination] [-f form-name] [-H special-handling] [-n number] [-o options] [-p pagenumbers] [-q priority-level] [-S character-set | print-wheel] [-t title] [-T content-Type [-r]] [-y mode-list]
Options
-- | Marks the end of options; use this to print a file whose name begins with a dash (-). |
-E | Forces encryption when connecting to the server. |
-U username | Specifies the username to use when connecting to the server. |
-c | This option is provided for backward compatibility only. On systems that support it, this option forces the print file to be copied to the spool directory before printing. In CUPS, print files are always sent to the scheduler via IPP which has the same effect. |
-d destination | Prints files to the destination printer. |
-h hostname[:port] | Chooses an alternate server. |
-i job-id | Specifies an existing job to modify. |
-m | Sends an e-mail when the job is completed. |
-n copies | Sets the number of copies to print from 1 to 100. |
-o "name=value [name=value ...]" | Sets one or more job options. |
-q priority | Sets the job priority from 1 (lowest) to 100 (highest). The default priority is 50. |
-s | Do not report the resulting job IDs (silent mode.) |
-t "name" | Sets the job name. |
-H hh:mm -H hold -H immediate -H restart -H resume |
Specifies when the job should be printed. A value of immediate prints the file immediately, a value of hold holds the job indefinitely, and a UTC time value (HH:MM) holds the job until the specified UTC (not local) time. Use a value of resume with the -i option to resume a held job. Use a value of restart with the -i option to restart a completed job. |
-P page-list | Specifies which pages to print in the document. The list can contain a list of numbers and ranges (#-#) separated by commas (e.g., 1,3-5,16). The page numbers refer to the output pages and not the document's original pages - options like "number-up" can affect the numbering of the pages. |
Options
Aside from the printer-specific options reported by the lpoptions command, the following generic options are available:
-o media=size | Sets the page size to size. Most printers support at least the size names "a4", "letter", and "legal". |
-o landscape -o orientation-requested=4 |
Prints the job in landscape orientation (rotated 90 degrees). |
-o sides=one-sided -o sides=two-sided-long-edge -o sides=two-sided-short-edge |
Prints on one or two sides of the paper. The value "two-sided-long-edge" is normally used when printing portrait (unrotated) pages, while "two-sided-short-edge" is used for landscape pages. |
-o fit-to-page | Scales the print file to fit on the page. |
-o number-up=2 -o number-up=4 -o number-up=6 -o number-up=9 -o number-up=16 |
Prints multiple document pages on each output page. |
-o cpi=N | Sets the number of characters per inch to use when printing a text file. The default is 10. |
-o lpi=N | Sets the number of lines per inch to use when printing a text file. The default is 6. |
-o page-bottom=N -o page-left=N -o page-right=N -o page-top=N |
Sets the page margins when printing text files. The values are in points - there are 72 points to the inch. |
Examples
lp -d myprinter -o media=legal -o sides=two-sided-long-edge file name
Prints the double-sided legal document file name to printer myprinter.
lp -d myprinter -o scaling=200 file name
Print document file name across 4 pages.
lp -d myprinter -o cpi=12 -o lpi=8 -o page-left=72 file name
Print a text file with 12 characters per inch, 8 lines per inch, and a 1 inch left margin.
Related commands
cancel — Cancels a print job under the System V operating system.
enable — Enable and disable LP printers.
lpq — List the status of available printers.
lpr — Submit print requests.
lprm — Remove requests from the print queue.
lpstat — List the status of the LP print services.
mail — Read, compose, and manage mail.
pr — Format a text file for printing.
stty — Set options for your terminal display.