Go to the U of M home page
School of Physics & Astronomy
School of Physics and Astronomy Wiki

User Tools


computing:department:unix:printing

This is an old revision of the document!


Printing from Unix

For complete information on printing commands and options, please refer to the CUPS (common unix printing system) User Manual at https://cups.physics.umn.edu/ (within Tate Lab) or http://www.cups.org/.

The command to print from a Unix system to any of our network printers is:

lpr -P printer filename

…where printer is the name of the print queue (usually the room number). The queues accept many file types directly, such as image files and PDF as well as text or Postscript.

You can use the lpstat(1) command to see a list of available printers:

lpstat -p -d

The -p option specifies that you want to see a list of printers, and the -d option reports the current default printer or class.

Changing printer settings in KDE

If you want to use the GUI printing configuration utility under Settings→Printers rather than lpoptions as described below, they will overwrite and lose any settings you have made manually. Please just use one of the two methods to change options.

Controlling printer features

Additional print options can be specified to select features such as duplex or portrait/landscape orientation. A huge number of options is available, and you should consult the CUPS manual for complete details, but some example options include:

  • Where multiple trays are available, you can select which tray to print from using the -o media switch. For example:
    lpr -o media=Upper filename
    lpr -o media=Lower filename
  • Most duplex-capable printers are set to print on both sides by default. You can control this behaviour using the -o sides switch.
    lpr -o sides=two-sided-long-edge filename
    lpr -o sides=two-sided-short-edge filename
    lpr -o sides=one-sided filename
  • You can control orientation using the -o landscape switch.
    lpr -o portrait filename
    lpr -o landscape filename

Finding other available options and setting defaults

Some of these options are quite wordy; however you can use the lpoptions command to set up default settings to suit your preference (see the CUPS user manual for details). To view the available options, and their current settings for a particular printer, use the lpoptions -l command - for example,

lpoptions -p 216 -l

The above “generic” options such as sides=two-sided-long-edge may not work for setting defaults. Instead, find the specific option for your printer from lpoptions -p printer -l, and use that. For example the option to set duplex printing on the 431 HP printer may be something like lpoptions -p 431 -o Duplex=DuplexNoTumble.

Setting a default printer

If you want to select a particular printer as default, use the lpoptions -d command. You can then use this printer without having to use the -P parameter. For example:

lpoptions -d 216

NOTE in the past, one would set the default printer by setting an environment variable PRINTER in your login script. You should remove any such setting in order to avoid unexpected interactions.

Viewing print jobs

You can check the contents and status of a print queue using the lpstat command. For example,

lpstat 216

You can check queue and job status online by checking the print server jobs listing (this link will only work within Tate Lab).

Printing to Toshiba copiers

To print to toshiba copiers you need to specify your Department printing code. This is tedious to specify on the CUPS command line, but it can be done using the DCDigit1… DCDigitX options (1-5 for 431, 1-7 for new toshiba copier 3sw).

Old Toshiba copier: 431

Say your Department Code is 10203. Your command to print would be:

lpr -P 358c -o DeptCode=True -o DCDigit1=1 -o DCDigit2=0 -o DCDigit3=2 -o DCDigit4=0 -o DCDigit1=5 filename

You can avoid having to specify the code every time, by storing it using lpoptions. For example, to first store your code and then print a file:

lpoptions -o DeptCode=True -o DCDigit1=1 -o DCDigit2=0 -o DCDigit3=2 -o DCDigit4=0 -o DCDigit5=3 -p 358c
lpr -P 358c filename

Note there are several possible places for your output to be delivered; you can control this using the OutputTray option. The default is the Inner tray (beneath the control panel).

New Toshiba copier: 3sw

To print to 3sw (new toshiba copier), like above but with 7 digits (prepend zeros to your number if you have less). Example for 1020304:

lpr -P 3sw -o DeptCode=True -o DCDigit1=1 -o DCDigit2=0 -o DCDigit3=2 -o DCDigit4=0 -o DCDigit5=5 -o DCDigit6=7 -o DCDigit7=1 filename

or

lpoptions -o DeptCode=True -o DCDigit1=1 -o DCDigit2=0 -o DCDigit3=2 -o DCDigit4=0 -o DCDigit5=3 -o DCDigit6=0 -o DCDigit7=4 -p 3sw
lpr -P 358c filename

Hint: Remote Printing

You can print to our print queues from a remote unix system, by piping your file through the “ssh” command. For example:

bash> cat myfile.ps |ssh ssh.physics.umn.edu "cat - |lpr -P342"

If you often need to print from a remote site, it should be fairly simple to embed these commands into a convenient script or alias. For example, if you use tsch:

tcsh> alias lp342 'cat \!\!:1 | ssh ssh.physics.umn.edu "lpr -P342"'
tcsh> lp342 myfile.ps

Or bash:

$ lp342() { cat $1 |ssh ssh.physics.umn.edu "lpr -P342" }
$ lp342 myfile.ps
computing/department/unix/printing.1341877752.txt.gz · Last modified: 2012/07/09 18:49 by allan