This chapter shows you how to submit, query, and cancel print jobs to different printers.
CUPS provides both the System V (lp(1)
) and Berkeley (
lpr(1)
) printing commands. Type the following command to print a
file to the default (or only) printer on the system:
lpr filename ENTER
CUPS understands many different types of files directly, including PostScript and image files. This allows you to print from inside your applications or at the command-line, whichever is most convenient!
Many systems will have more than one printer available to the user. These printers can be attached to the local system via a parallel, serial, or USB port, or available over the network.
Use the lpstat(1)
command to see a list of available
printers:
lpstat -p -d ENTER
The -p
option specifies that you want to see a list of
printers, and the -d
option reports the current default
printer or class.
Use the -P
option with the lpr
command to print to a specific printer:
lpr -P printer filename ENTER
For many types of files, the default printer options may be sufficient for your needs. However, there may be times when you need to change the options for a particular file you are printing.
The
lpr
commands allow you to pass
printer options using the -o
option:
lpr -o landscape -o scaling=75 -o media=A4 filename.jpg
The lpr
command has options for printing more than one
copy of a file:
lpr -#num-copies filename ENTER
Copies are normally not collated for you. Use the -o
Collate=True
option to get collated copies :
lpr -#num-copies -o Collate=True filename ENTER
The lpstat
command can be used to check for jobs that
you have submitted for printing:
lpstat ENTER
Printer-1 johndoe 4427776
Printer-2 johndoe 15786
Printer-3 johndoe 372842
The jobs are listed in the order they will be printed. Use the
-p
option to see which files and printers are active:
lpstat -p ENTER
printer DeskJet now printing DeskJet-1.
Use the -o
and -p
options together to show
the jobs and the printers:
lpstat -o -p ENTER
Printer-1 johndoe 4427776
Printer-2 johndoe 15786
Printer-3 johndoe 372842
printer DeskJet now printing DeskJet-1.
Since CUPS uses the Internet Printing Protocol, it is also a fully-functional web server. To use your web browser to monitor the printers on your system, open the URL:
http://localhost:631
From there you can view the status of classes, jobs, and printers with the click of a button!
The cancel(1)
and lprm(1)
commands cancel
a print job:
cancel job-id ENTER
lprm job-id ENTER
The job-id
is the number that was reported to you by
the lp
or lpstat
commands.
This chapter describes the standard printer options that are
available when printing with the lp
and lpr
commands.
The following options apply when printing all types of files.
The -o media=xyz
option sets the media size, type,
and/or source:
lpr -o media=Letter,Transparency filename ENTER
lpr -o media=Letter,MultiPurpose,Transparency filename ENTER
The available media sizes, types, and sources depend on the printer, but most support the following options (case is not significant):
Letter
- US Letter (8.5x11 inches, or 216x279mm)Legal
- US Legal (8.5x14 inches, or 216x356mm)A4
- ISO A4 (8.27x11.69 inches, or 210x297mm)COM10
- US #10 Envelope (9.5x4.125 inches, or
241x105mm)DL
- ISO DL Envelope (8.66x4.33 inches, or 220x110mm)Transparency
- Transparency media type or sourceUpper
- Upper paper trayLower
- Lower paper trayMultiPurpose
- Multi-purpose paper trayLargeCapacity
- Large capacity paper trayThe actual options supported are defined in the printer's PPD file
in the PageSize
, InputSlot
, and MediaType
options.
The -o landscape
option will rotate the page 90 degrees
to print in landscape orientation:
lpr -o landscape filename ENTER
The -o sides=two-sided-short-edge
and -o
sides=two-sided-long-edge
options will enable duplexing on the
printer, if the printer supports it. The -o
sides=two-sided-short-edge
option is suitable for landscape
pages, while the -o sides=two-sided-long-edge
option is
suitable for portrait pages:
lpr -o sides=two-sided-long-edge filename ENTER
The following options apply when printing all types of files.
The -o page-ranges=pages
option selects a range of
pages for printing:
lpr -o page-ranges=1-4,7,9-12 filename ENTER
As shown above, the pages
value can be a single page, a
range of pages, or a collection of page numbers and ranges separated by
commas. The pages will always be printed in ascending order, regardless
of the order of the pages in the page-ranges
option.
The default is to print all pages.
Use the -o page-set=set
option to select the even or
odd pages:
lpr -o page-set=even filename ENTER
The default is to print all pages.
The the -o outputorder=order
option to set the output
order of all pages:
lpr -o outputorder=reverse filename ENTER
The -o number-up=value
option selects N-Up printing.
N-Up printing places multiple document pages on a single printed page.
CUPS supports 1, 2, 4, 6, 9, and 16-Up formats; the default format is
1-Up:
lpr -o number-up=16 filename ENTER
The -o page-border=value
option chooses the border to
draw around each page:
-o page-border=double
; draw two hairline borders
around each page-o page-border=double-thick
; draw two 1pt borders
around each page-o page-border=none
; do not draw a border (default)-o page-border=single
; draw one hairline border
around each page-o page-border=single-thick
; draw one 1pt border
around each pageThe -o number-up-layout=value
option chooses the layout
of the pages on each output page:
-o number-up-layout=btlr
; Bottom to top, left to
right-o number-up-layout=btrl
; Bottom to top, right to
left-o number-up-layout=lrbt
; Left to right, bottom to
top-o number-up-layout=lrtb
; Left to right, top to
bottom (default)-o number-up-layout=rlbt
; Right to left, bottom to
top-o number-up-layout=rltb
; Right to left, top to
bottom-o number-up-layout=tblr
; Top to bottom, left to
right-o number-up-layout=tbrl
; Top to bottom, right to
leftYou can mirror a print using the -o mirror
option:
lpr -o mirror filename ENTER
This is useful for printing mirrored pages on transfer paper, for T shirts, mugs, etc.
You can control the overall brightness of the printed output using
the -o brightness=percent
option:
lpr -o brightness=120 filename ENTER
Values greater than 100 will lighten the print, while values less than 100 will darken it.
You can control the overall gamma correction of the printed output
using the -o gamma=value
option:
lpr -o gamma=1700 filename ENTER
Values greater than 1000 will lighten the print, while values less than 1000 will darken it. The default gamma is 1000.
The following options apply when printing text files.
The -o cpi=value
option sets the number of characters
per inch:
lpr -o cpi=17 filename ENTER
The default characters per inch is 10.
The -o lpi=value
option sets the number of lines per
inch:
lpr -o lpi=8 filename ENTER
The default lines per inch is 6.
The -o columns=value
option sets the number of text
columns:
lpr -o columns=3 filename ENTER
The default number of columns is 1.
Normally the page margins are set to the hard limits of the printer.
Use the -o page-left=value
, -o page-right=value
, -o page-top=value
, and -o page-bottom=value
options to adjust the page margins:
lpr -o page-bottom=value filename ENTER
The value
argument is the margin in points; each point
is 1/72 inch or 0.35mm.
The -o prettyprint
option puts a header at the top of
each page with the page number, job title (usually the filename), and
the date. Also, C and C++ keywords are highlighted, and comment lines
are italicized:
lpr -o prettyprint filename ENTER
The following options apply when printing image files.
The -o position=name
option specifies the position of
the image on the page:
center
- Center the image on the page (default)top
- Print the image centered at the top of the pageleft
- Print the image centered on the left of pageright
- Print the image centered on the right of the
pagetop-left
- Print the image at the top left corner of
the pagetop-right
- Print the image at the top right corner
of the pagebottom
- Print the image centered at the bottom of
the pagebottom-left
- Print the image at the bottom left
corner of the pagebottom-right
- Print the image at the bottom right
corner of the pageThe -o scaling=percent
, -o ppi=value
,
and -o natural-scaling=percent
options change the size of
a printed image:
lpr -o natural-scaling=percent filename ENTER
The scaling=percent
value is a number from 1 to 800
specifying the size in relation to the page (not the image.) A
scaling of 100 percent will fill the page as completely as the image
aspect ratio allows. A scaling of 200 percent will print on up to 4
pages.
The ppi=value
value is a number from 1 to 1200
specifying the resolution of the image in pixels per inch. An image
that is 3000x2400 pixels will print 10x8 inches at 300 pixels per inch,
for example. If the specified resolution makes the image larger than
the page, multiple pages will be printed to satisfy the request.
The natural-scaling=percent
value is a number from 1 to
800 specifying the size in relation to the natural image size. A
scaling of 100 percent will print the image at its natural size, while
a scaling of 50 percent will print the image at half its natural size.
If the specified scaling makes the image larger than the page, multiple
pages will be printed to satisfy the request.
The -o hue=value
option will adjust the hue of the
printed image, much like the tint control on your television:
lpr -o hue=value filename ENTER
The value
argument is a number from -360 to 360 and
represents the color hue rotation. The following table summarizes the
change you'll see with different colors:
Original | hue=-45 | hue=45 |
---|---|---|
Red | Purple | Yellow-orange |
Green | Yellow-green | Blue-green |
Yellow | Orange | Green-yellow |
Blue | Sky-blue | Purple |
Magenta | Indigo | Crimson |
Cyan | Blue-green | Light-navy-blue |
The default hue adjustment is 0.
The -o saturation=percent
option adjusts the saturation
of the colors in an image, much like the color knob on your television:
lpr -o saturation=percent filename ENTER
The percent
argument specifies the color saturation
from 0 to 200. A color saturation of 0 produces a black-and-white
print, while a value of 200 will make the colors extremely intense.