User Tools

Site Tools


This is an old revision of the document!

Printing from command line

For a description of the printers available to Linux machines refer to printing

On the Linux system the printing is handled by a central print-spooler. The spooler queues, format (if necessary) and send the file to the printer. The spooler is in our case called . In the normal case the file you want to print should be a postscript-file. All our printers understand postscript and PDF. One typical format is “text”, but even a lot of other formats is possible. The spooler takes care of the file, and try to do its best to convert it to postscript before it is sent to the printer. However, in most cases, might be required that you convert the files to postscript yourself.

To print a document “” to the default printer, use


To print to another printer (newprinter in this example) use

lpr -P newprinter

See what is in the print queue

  lpq -P copy_t

Remove all your printouts from the queue

  lprm -
  lprm - -P printer


Printers that are able to print duplex, do that by default, and are flipping the page along the long edge. To print in simplex (only on one side of the paper)

  lpr -o sides=one-sided

To print on both sides and flip along the short edge

  lpr -o sides=two-sided-short-edge

To print on both sides and flip along the long edge (default)

lpr -o sides=two-sided-long-edge
  lpr -o page-ranges=4
  lpr -o page-ranges=1-8
  lpr -o page-ranges=1,3,6

Pretty printing

This option is only useful when printing text files.

Specifies that the file should be formatted with a shaded header with the date, time, job name, and page number.

  lpr -p


lpr -o prettyprint

To print two pages on each side of the paper

lpr -o number-up=2

And to get in even more on the paper

lpr -o number-up=4

You can also use 8 and 16. But can you read it?


To rotate the page 90 degrees and print it in landscape orientation

lpr -o landscape

In most cases it is better to create the file in landscape orientation.


lpr -o mirror

Might be useful if you want to print something that Leonardo D. has written.

Combining options

You can combine the options, like in the following example

lpr -P newprinter -o prettyprint -o number-up=2

Other useful utilities

ps2ps can do a lot of tricks on a postscript-file. It is used in the background of the printing system to handle many of the options above, but can be used directly on a file. ps2ps can sometimes be used to “clean up” ps or eps files originating from other systems.

psbook is useful to rearrange the pages in a ps-file in such a way that when printed, you can fold the papers around the middle, and you have got a book. Or at least a booklet. Se

man psbook

for more information.

gv or ghostview, is the number one program to check a ps-file before printing it. It can save many trees – but nowadays you're used to this.


it_services/mf/printing_cmdline.1410969116.txt.gz · Last modified: 2014/09/17 17:51 by florido