lp print command builder
Print from the command line
On a Mac or Linux machine, lp and lpr send a file to any printer with the copies, sides, paper and pages set. Pick the job and get the one line to paste in Terminal, then paste what lpoptions says to see what that printer can do. It runs in your browser: nothing you type or paste is sent to us.
Run this in Terminal
On a Mac, open Terminal and cd to the file's folder first, or type its full path. On Linux, lp comes with CUPS. Windows has no lp; run it from a Mac or Linux machine, or Windows Subsystem for Linux with CUPS installed.
lp -d Copy_Room_Colour -n 25 -o sides=two-sided-long-edge -o media=Letter -o print-color-mode=monochrome -o collate=true worksheet.pdf- -d Copy_Room_Colour
- Sends it to Copy_Room_Colour.
- -n 25
- 25 copies.
- -o sides=two-sided-long-edge
- Both sides, flipped like a book. For portrait pages.
- -o media=Letter
- On Letter, 8.5 by 11 paper.
- -o print-color-mode=monochrome
- In black and white, even on a colour printer.
- -o collate=true
- Each copy comes out as a full set, in order.
lp answers with a request id such as Copy_Room_Colour-112. A printer ignores an option it does not have, so check the first copy.
What can this printer do?
Run the second line, paste what it prints, and see its sides, paper, colour and finishing options.
lpstat -p -dLists every printer by the name lp needs, and which one is the default.
lpoptions -p Copy_Room_Colour -lLists the options this printer takes. Paste what it prints below.
lpstat -oShows the jobs waiting, each with its job ID; cancel ID removes one.
lp command options for a school job
These are the standard CUPS options, which lp and lpr share; only the printer and copies flags differ. Settings like duplex, pages per sheet and collate mean the same here as in a print dialog. Run man lp for the full list.
| lp | lpr | What it does |
|---|---|---|
| -d NAME | -P NAME | The printer, by its CUPS queue name. Left out, the job goes to the default printer. |
| -n 25 | -# 25 | How many copies. |
| -o sides=two-sided-long-edge | same | Double-sided for portrait pages. two-sided-short-edge for landscape, one-sided to turn it off. |
| -o media=Letter | same | The paper size, by the name lpoptions lists, such as Letter, Legal or Tabloid. |
| -o page-ranges=1-3,5 | same | Only some pages of the file, in order. |
| -o number-up=2 | same | 2, 4, 6, 9 or 16 pages shrunk onto each side. |
| -o print-color-mode=monochrome | same | Black and white on a colour printer. Some drivers use their own name, such as ColorModel=Gray. |
| -o collate=true | same | Each copy comes out as a full set. |
| -o landscape | same | Turns the pages a quarter turn. |
| -o fit-to-page | same | Scales each page to the printable area. |
lp or lpr?
Either. Both hand the job to CUPS, which sends it to the printer over IPP or whatever the queue was added with. lpr is the older BSD form, not the LPR protocol on port 515. A job that will not leave is cleared with the print queue clear command.
Queue names
lpstat -p lists them. macOS writes spaces in a printer's name as underscores.
Set a default
lpoptions -d NAME makes a printer the default for lp with no -d.
Keep options
lpoptions -p NAME -o sides=two-sided-long-edge saves it for every later job to that printer.
Unknown option
A printer quietly ignores an option it lacks. Print one copy first and check it.
Take it further
- Print queue clear commandA job that will not leave? The Mac Terminal lines to cancel it and restart CUPS.
- Page range checkerCheck a range like 1-3,5 against the file before it goes in page-ranges=.
- Long edge vs short edgeWhich sides= value keeps the back of the page the right way up.
- Printer address builderNot added yet? The ipp address to add the printer with lpadmin or System Settings.
Teachers send the file, not a command.
This builder writes one job from one computer. In KyberCopy teachers send from the request form, a preset carries the sides, paper and colour, it is checked against what each printer reports, and the relay prints it over IPP or port 9100.
Book a demo