CUPS provides both the System V (lp(1)) and Berkeley (lpr(1)) printing commands for printing files. In addition, it supported a large number of standard and printer-specific options that allow you to control how and where files are printed.
This guide is taken from the Common Unix Printing System (CUPS) documentation. It is available on any system running CUPS (e.g. EECS Ubuntu Linux Desktops) at http://localhost:631/help/options.html. You can also find CUPS documentation at www.cups.org.
CUPS understands many different types of files directly, including text, PostScript, PDF, and image files. This allows you to print from inside your applications or at the command-line, whichever is most convenient! Type either of the following commands to print a file to the default (or only) printer on the system:
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
The option specifies that you want to see a list of printers, and the
-d option reports the current default printer or class.
-d option with the lp command to print to a specific printer:
lp -d printer filename
-P option with the lpr command:
lpr -P printer filename
If you normally use a particular printer, you can tell CUPS to use it by default using the lpoptions(1) command:
lpoptions -d printer
Both the lp and lpr commands support printing from the standard input:
program | lp
program | lp -d printer
program | lpr
program | lpr -P printer
If the program does not provide any output, then nothing will be queued for printing.
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 lp and lpr commands allow you to pass printer options using the
lp -o landscape -o scaling=75 -o media=A4 filename.jpg
lpr -o landscape -o scaling=75 -o media=A4 filename.jpg
The available printer options vary depending on the printer. The standard options are described in the Standard Printing Options section below. Printer-specific options are also available and can be listed using the lpoptions command:
lpoptions -p printer -l
Saved options are supported in CUPS through printer instances. Printer instances are, as their name implies, copies of a printer that have certain options associated with them. Use the lpoptions command to create a printer instance:
lpoptions -p printer/instance -o name=value ...
-p printer/instance option provides the name of the instance, which is always the printer name, a slash, and the instance name which can contain any printable characters except space and slash. The remaining options are then associated with the instance instead of the main queue. For example, the following command creates a duplex instance of the LaserJet queue:
lpoptions -p LaserJet/duplex -o sides=two-sided-long-edge
Instances do not inherit lpoptions from the main queue.
Both the lp and lpr commands have options for printing more than one copy of a file:
lp -n num-copies filename
lpr -#num-copies filename
Copies are normally not collated for you. Use the ”-o Collate=True” option to get collated copies:
lp -n num-copies -o Collate=True filename
lpr -#num-copies -o Collate=True filename
The cancel(1) and lprm(1) commands cancel a print job:
The job-id is the number that was reported to you by the lp command. You can also get the job ID using the lpq(1) or lpstat commands:
The lpmove(8) command moves a print job to a new printer or class:
lpmove job-id destination
The job-id is the number that was reported to you by the lp or lpstat commands. Destination is the name of a printer or class that you want to actually print the job.
Note: The lpmove command is located in the system command directory (typically /usr/sbin or /usr/local/sbin), and so may not be in your command path. Specify the full path to the command if you get a "command not found" error, for example:
/usr/sbin/lpmove foo-123 bar
The following options apply when printing all types of files.
-o media=xyz option sets the media size, type, and/or source:
lp -o media=Letter filename
lp -o media=Letter,MultiPurpose filename
lpr -o media=Letter,Transparency filename
lpr -o media=Letter,MultiPurpose,Transparency filename
The available media sizes, types, and sources depend on the printer, but most support the following options (case is not significant):
The actual options supported are defined in the printer's PPD file in the “PageSize”, “InputSlot”, and “MediaType” options. You can list them using the lpoptions(1) command:
lpoptions -p printer -l
When “Custom” is listed for the “PageSize” option, you can specify custom media sizes using one of the following forms:
lp -o media=Custom.WIDTHxLENGTH filename
lp -o media=Custom.WIDTHxLENGTHin filename
lp -o media=Custom.WIDTHxLENGTHcm filename
lp -o media=Custom.WIDTHxLENGTHmm filename
where “WIDTH” and “LENGTH” are the width and length of the media in points, inches, centimeters, or millimeters, respectively.
The ”-o landscape” option will rotate the page 90 degrees to print in landscape orientation:
lp -o landscape filename lpr -o landscape filename
The ”-o orientation-requested=N” option rotates the page depending on the value of N:
-o sides=two-sided-short-edge and
-o sides=two-sided-long-edge options will enable two-sided printing 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:
lp -o sides=two-sided-short-edge filename lp -o sides=two-sided-long-edge filename lpr -o sides=two-sided-long-edge filename
The default is to print single-sided:
lp -o sides=one-sided filename lpr -o sides=one-sided filename
-o jobsheets=start,end option sets the banner page(s) to use for a job:
lp -o job-sheets=none filename lp -o job-sheets=standard filename lpr -o job-sheets=classified,classified filename
If only one banner file is specified, it will be printed before the files in the job. If a second banner file is specified, it is printed after the files in the job.
The available banner pages depend on the local system configuration; CUPS includes the following banner files:
-o job-hold-until=when option tells CUPS to delay printing until the
when time, which can be one of the following:
Aside from the web interface, you can use the lp command to release a held job:
lp -i job-id -H resume
where “job-id” is the job ID reported by the lpstat command.
-o job-priority=NNN option tells CUPS to assign a priority to your job from 1 (lowest) to 100 (highest), which influences where the job appears in the print queue. Higher priority jobs are printed before lower priority jobs, however submitting a new job with a high priority will not interrupt an
-o outputorder=normal and
-o outputorder=reverse options specify the order of the pages. Normal order prints page 1 first, page 2 second, and so forth. Reverse order prints page 1 last.
-o page-ranges=pages option selects a range of pages for printing:
lp -o page-ranges=1 filename lp -o page-ranges=1-4 filename lp -o page-ranges=1-4,7,9-12 filename lpr -o page-ranges=1-4,7,9-12 filename
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.
-o page-set=set option to select the even or odd pages:
lp -o page-set=odd filename lp -o page-set=even filename lpr -o page-set=even filename
The default is to print all pages.
-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:
lp -o number-up=1 filename lp -o number-up=2 filename lp -o number-up=4 filename lpr -o number-up=16 filename
-o page-border=value option chooses the border to draw around each page:
-o number-up-layout=value option chooses the layout of the pages on each output page:
-o fitplot option specifies that the document should be scaled to fit on the page:
lp -o fitplot filename lpr -o fitplot filename
The default is to use the size specified in the file.
Note:This feature depends upon an accurate size in the print file. If no size is given in the file, the page may be scaled incorrectly!
-o outputorder=reverse option will print the pages in reverse order:
lp -o outputorder=reverse filename lpr -o outputorder=reverse filename
-o outputorder=normal option will print starting with page 1:
lp -o outputorder=normal filename lpr -o outputorder=normal filename
The default is
-o outputorder=normal for printers that print face down and
-o outputorder=reverse for printers that print face up.
-o mirror option flips each page along the vertical access to produce a mirrored image:
lp -o mirror filename lpr -o mirror filename
This is typically used when printing on T-shirt transfer media or sometimes on transparencies.
-o raw option allows you to send files directly to a printer without filtering. This is sometimes required when printing from applications that provide their own “printer drivers” for your printer:
lp -o raw filename lpr -o raw filename
-l option can also be used with the lpr command to send files directly to a printer:
lpr -l filename
CUPS supports several options that are only used when printing plain text files. These options have absolutely no effect on PostScript, PDF, HP-GL/2, or image files.
-o cpi=value option sets the number of characters per inch:
lp -o cpi=10 filename lp -o cpi=12 filename lpr -o cpi=17 filename
The default characters per inch is 10.
-o lpi=value option sets the number of lines per inch:
lp -o lpi=6 filename lpr -o lpi=8 filename
The default lines per inch is 6.
-o columns=value option sets the number of text columns:
lp -o columns=2 filename lpr -o columns=3 filename
The default number of columns is 1.
Normally the page margins are set to the hard limits of the printer. Use the
-o page-top=value, and
-o page-bottom=value options to adjust the page margins:
lp -o page-left=value filename lp -o page-right=value filename lp -o page-top=value filename lp -o page-bottom=value filename lpr -o page-left=value -o page-right=value -o page-top=value -o page-bottom=value filename
value argument is the margin in points; each point is 1/72 inch or 0.35mm.
-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:
lp -o prettyprint filename lpr -o prettyprint filename
-o nowrap option disables wrapping of long lines:
lp -o nowrap filename lpr -o nowrap filename
CUPS supports several options that are only used when printing image files. These options have absolutely no effect on PostScript, PDF, HP-GL/2, or text files.
-o position=name option specifies the position of the image on the page:
-o ppi=value, and
-o natural-scaling=percent options change the size of a printed image:
lp -o scaling=percent filename lp -o ppi=value filename lpr -o natural-scaling=percent filename
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.
ppi=value value is a number from 1 to 1200 specifying the resolution of the image in pixels per inch. An image that is 3000×2400 pixels will print 10×8 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.
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.
-o hue=value option will adjust the hue of the printed image, much like the tint control on your television:
lp -o hue=value filename lpr -o hue=value filename
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:
The default hue adjustment is 0.
-o saturation=percent option adjusts the saturation of the colors in an image, much like the color control on your television:
lp -o saturation=percent filename lpr -o saturation=percent filename
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.
The default saturation is 100.
CUPS supports several options that are only used when printing HP-GL/2 files. These options have absolutely no effect on PostScript, PDF, image, or text files.
-o blackplot option specifies that all pens should plot in black:
lp -o blackplot filename lpr -o blackplot filename
The default is to use the colors defined in the plot file or the standard pen colors defined in the HP-GL/2 reference manual from Hewlett Packard.
-o penwidth=value option specifies the default pen width for HP-GL/2 files:
lp -o penwidth=value filename lpr -o penwidth=value filename
The pen width
value specifies the pen width in micrometers. The default value of 1000 produces lines that are 1 millimeter in width. Specifying a pen width of 0 produces lines that are exactly 1 pixel wide.
Note: This option is ignored when the pen widths are set in the plot file.s
Knoxville, Tennessee 37996 | 865-974-1000
The flagship campus of the University of Tennessee System