lp(1)

๐Ÿ’– lp(1) โ€” bestie's guide to printing files ๐Ÿ’–

okay so this is the lp(1) page from the OpenPrinting manual, and honestly? it's iconic. it's the command that sends your stuff to the printer, and i'm gonna walk you through every single flag like we're sitting on the floor of my room with iced coffee. no cap. ๐ŸŽ€


โœจ NAME โœจ

lp โ€” print files ๐Ÿ–จ๏ธ๐Ÿ’…


๐ŸŒธ SYNOPSIS ๐ŸŒธ

lp [ -h hostname[:port] ] [ -E ] [ -U username ] [ -c ] [ -d
destination[/instance] ] [ -m ] [ -n num-copies ] [ -o option[=value] ]
[ -q priority ] [ -s ] [ -t title ] [ -H handling ] [ -P page-list ] [
-- ] [ file(s) ]
lp [ -h hostname[:port] ] [ -E ] [ -U username ] [ -c ] [ -i job-id ] [
-n num-copies ] [ -o option[=value] ] [ -q priority ] [ -t title ] [ -H
handling ] [ -P page-list ]

like, two whole forms โ€” one for printing files, one for messing with a job that's already out there. slay. โœจ


๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

lp submits files for printing, or alters a pending job. that's the whole vibe. ๐Ÿซถ

and listen โ€” if you use a filename of "-", it forces printing from the standard input. stdin girlies rise. ๐Ÿ˜ญ

๐Ÿ‘‘ THE DEFAULT DESTINATION ๐Ÿ‘‘

CUPS has so many ways to set the default destination, it's giving "too many options" energy. here's the actual order, bestie:

  1. the LPDEST and PRINTER environment variables get consulted first ๐Ÿฅ‡
  2. if neither of those is set, it uses the current default set by the lpoptions(1) command
  3. and after that, the default set by the lpadmin(8) command

periodt. that's the priority list. don't fight it.


๐Ÿ’… OPTIONS ๐Ÿ’…

the following options are recognized by lp โ€” and yes, we're doing ALL of them. every single one. ๐Ÿ’–

  • -- โ€” marks the end of options. use this when you wanna print a file whose name begins with a dash (-). the classic gotcha, we love her.
  • -E โ€” forces encryption when connecting to the server. ๐Ÿ”’ secure girl behavior.
  • -U username โ€” specifies the username to use when connecting to the server.
  • -c โ€” okay so this one is provided for backwards-compatibility only. on systems that support it, it 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 anyway. so like. it's fine. it's giving legacy. ๐Ÿ™ˆ
  • -d destination โ€” prints files to the named printer. ๐ŸŽฏ
  • -h hostname[:port] โ€” chooses an alternate server. โš ๏ธ note: this option must occur before all others. like, BEFORE. ALL. OTHERS. it's the main character, it goes first. ๐Ÿ‘‘
  • -i job-id โ€” specifies an existing job to modify. this is your "edit an already-posted post" energy. โœ๏ธ
  • -m โ€” sends an email when the job is completed. ๐Ÿ“ง so 2010s of it but okay bestie.
  • -n copies โ€” sets the number of copies to print. ๐Ÿ’ฏ
  • -o "name=value [ ... name=value ]" โ€” sets one or more job options. see COMMON JOB OPTIONS below, we get into it. โœจ
  • -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.) ๐Ÿคซ mysterious. elusive. not like the other flags.
  • -t "name" โ€” sets the job name. ๐Ÿท๏ธ
  • -H hh:mm
  • -H hold
  • -H immediate
  • -H restart
  • -H resume โ€” specifies when the job should be printed. here's the breakdown, bestie:
    • a value of immediate will print the file immediately โšก
    • a value of hold will hold the job indefinitely ๐ŸงŠ
    • a UTC time value (HH:MM) will hold the job until the specified UTC (not local!) time โฐ not local, fr fr
    • 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". IMPORTANT: 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. ๐Ÿ˜ญ so like, don't come for me when page 3 isn't page 3.

๐Ÿ“ COMMON JOB OPTIONS ๐Ÿ“

aside from the printer-specific options reported by the lpoptions(1) command, the following generic options are available โ€” and they're lowkey the most useful part of this whole page:

  • -o job-sheets=name โ€” prints a cover page (banner) with the document. the "name" can be "classified", "confidential", "secret", "standard", "topsecret", or "unclassified". ๐Ÿ•ต๏ธ drama. intrigue. a banner.
  • -o media=size โ€” sets the page size to size. most printers support at least the size names "a4", "letter", and "legal". ๐Ÿ“„
  • -o number-up={2|4|6|9|16} โ€” prints 2, 4, 6, 9, or 16 document (input) pages on each output page. ๐Ÿ—‚๏ธ it's giving "cramming for finals."
  • -o orientation-requested=4 โ€” prints the job in landscape (rotated 90 degrees counter-clockwise). ๐Ÿ”„
  • -o orientation-requested=5 โ€” prints the job in landscape (rotated 90 degrees clockwise). ๐Ÿ”ƒ
  • -o orientation-requested=6 โ€” prints the job in reverse portrait (rotated 180 degrees). ๐Ÿ™ƒ upside down and unbothered.
  • -o print-as-raster โ€” prints the job as raster. ๐Ÿ–ผ๏ธ
  • -o print-quality=3
  • -o print-quality=4
  • -o print-quality=5 โ€” specifies the output quality: draft (3), normal (4), or best (5). โœจ
  • -o sides=one-sided โ€” prints on one side of the paper. ๐Ÿƒ
  • -o sides=two-sided-long-edge โ€” prints on both sides of the paper for portrait output. ๐Ÿ“–
  • -o sides=two-sided-short-edge โ€” prints on both sides of the paper for landscape output. ๐Ÿ“•

โญ CONFORMING TO โญ

unlike the System V printing system, CUPS allows printer names to contain any printable character except SPACE, TAB, "/", or "#". iconic, flexible, unbothered. also โ€” printer and class names are not case-sensitive. ๐Ÿ’…

and now for the numbers bit, bestie, because it trips people up: the -q option accepts a different range of values than the Solaris lp command. it matches the IPP job priority values (1-100, 100 is highest priority) instead of the Solaris values (0-39, 0 is highest priority). โš ๏ธ so if you're used to Solaris, your brain is gonna do a little flip.


๐Ÿ”ฅ EXAMPLES ๐Ÿ”ฅ

print two copies of a document to the default printer:

lp -n 2 filename

print a double-sided legal document to a printer called "foo":

lp -d foo -o media=legal -o sides=two-sided-long-edge filename

print a presentation document 2-up to a printer called "bar":

lp -d bar -o number-up=2 filename

ate. no crumbs. ๐Ÿซถ


๐Ÿ‘€ SEE ALSO ๐Ÿ‘€

cancel(1), lpadmin(8), lpoptions(1), lpq(1), lpr(1), lprm(1), lpstat(1), CUPS Online Help (http://localhost:631/help) ๐Ÿฆ‹


Copyright ยฉ 2020-2024 by OpenPrinting. ๐Ÿ’œ


okay bestie, that's the whole page โ€” and for the sign-off: this beauty is from CUPS, dated 2022-05-02, and it's the lp(1) page. go forth and print. you're gonna slay. ๐ŸŽ€โœจ๐Ÿ’–