Printing in Linux

Printing with Linux on our cluster

Author: L.S.Lowe. File: linuxprint. This update: 20121020. Part of Guide to the Local System.

Printing from desktop machine Linux

Each desktop machine normally has access to a full set of configured printers. These PP group printers are known by two-letter name destinations (such as jx) and can be used from a variety of applications like a web browser like Firefox, or office software like OpenOffice, from a generic printing command like kprinter, or (with less flexibility) from the command line using the usual Linux lpr -P dest command, or the lp -d dest command:

Name Type Model Room ColourPostScript Banner page
default
Medium
default
Max
size
jx Laserjet HP 4300dtn W331 No Yes Yes Paper 2-sided A4
kx Laserjet HP 4300dtn W2areaNo Yes Yes Paper 2-sided A4
mx Laserjet HP 5si W331 No Yes Yes Paper 2-sided A3
st inkjet Epson 3000 W331 Yes Yes* No No default A2**
px Solid inkXerox Phaser 8550W331Yes Yes Yes Paper 2-sided A4
qx Solid inkXerox ColorQube 8870W331Yes Yes Yes Paper 2-sided A4
tx (off!) Solid inkTektronix Phaser 850 W331Yes Yes Yes Paper 2-sided A4
zx (limited)Laserjet HP CP1525n PB08Yes Yes No Paper 1-sided A4

Printing from your Linux laptop

When doing this from home, see our Home PC page. When in the group area, you have a choice of any one of:
  • Do a export CUPS_SERVER=epcups.ph.bham.ac.uk, before your lp/lpr command
  • Modify your /etc/cups/client.conf: ServerName epcups.ph.bham.ac.uk
  • Specify lpr -H cups.ph.bham.ac.uk -P jx, for example
  • Specify lp -h cups.ph.bham.ac.uk -d jx, for example

The default printer

The initial value of your PRINTER variable on your desktop machine is set to jx for users with offices on West floor 3, and kx otherwise. The printer to be used can be set by the -P option of lpr.

Your default printer can be overridden by setting the environment variable PRINTER in your $HOME/.profile: for example:

        export PRINTER=jx 

According to man lp, CUPS provides many ways to set the default destination. The "LPDEST" and "PRINTER" environment variables are consulted first. If neither are set, the current default set using the lpoptions(1) command is used, followed by the default set using the lpadmin(8)command [by the administrator on the print server]. But at the time of writing, for SL5 and Fedora 12, a default set by the lpoptions -d command doesn't seem to be used by the lp or lpr commands, even if LPDEST and PRINTER are unset first.

Resetting printer options to their defaults

The CUPS printing system remembers some of your settings of the printer, so it's possible that if you set an option in (say) gwenview, then this option is remembered next time you use the same command, or a different command like lpr. This may be useful or it can be annoying.

To clear these personal definitions for a printer, type in

         lpoptions -x  printername 

To clear a definition for a particular option only, type in

         lpoptions -p printername -r OptionName 

You can list current options for a particular printer, whether your own options, or those in /etc/cups/lpoptions (currently empty on our system), or those defined by the remote printer server, by typing in

         lpoptions -p printername 
If no printer is specified, your default printer is listed.

(Note: the file whose contents are affected by these commands at the time of writing is $HOME/.lpoptions for SL4, and $HOME/.cups/lpoptions for SL5 and later systems, though if the former is present it is still processed).

Specifing options for the printers

If all you want to do is to print out a postscript file to the printer and accept all the local defaults, you don't need to worry about printer options. Otherwise, you would be wise to use one of the GUI methods of printing files, like using a built-in interface in applications like Firefox and OpenOffice or KWrite (below), or a generic print command like kprinter, because they are much easier to understand and will be fully supported.

Printing an image file using gwenview

To print an image like a JPEG or PNG image, you can use gwenview. Invoke gwenview with the filename, choose File / Print, choose the printer; then in Properties, choose the orientation Portrait or Landscape, and under the Advanced tab, scroll down to Print Quality, double-click the value on the right, and choose High Resolution Photo; further down, select Paper type of Plain paper or Transparency. (Previously, you had to select media source (tray 2 or 3), but not now; specifying Paper types of Transparency didn't work for gwenview in Fedora 12 when first released). Then click OK to return to the Print dialogue. Then expand Options, and under the Image Settings tab, choose the options you want. For example, to print a particular size, in centimetres or inches, use the Scale To button and enter the size you want. Then click Print.

Printing an image file using kprinter

(experimental) To print an image like a PNG image, using kprinter, invoke kprinter with the filename; choose the printer; in the Properties window, for the px printer under the General tab, choose a Paper type of Plain Paper or Transparency; still under the Properties window, choose the Image tab, and under Image Size choose the % of Page option and choose what per-cent coverage you want; (if you do not do this and allow the Natural Image size, then a large image may be spread over several output pages); then click OK and then click Print. N.B. this is experimental and the image size is not correct for the px printer under Fedora 12 at the time of writing, but is correct for the jx printer.

Command line printing options for a postscript or text file

When using the basic lpr command, rather than an application printing window or the kprinter window, there are various command-line options you can specify. Some of these are general, some only apply when printing plain text files. Have a look at the CUPS page Command line printing and options.

Local commands specifying options for the printers (obsolescent method)

Because the lpr and lp commands didn't provide an easy-to-use method of passing options to the printer, you were wise to avoid using them for non-default printing. There are some old locally-provided commands for specifying printer options, described here, but you are not recommended to use them because they are no longer fully supported. Be aware that your options will be overridden if the PostScript file contains commands which set these options differently. Only PostScript files which allow local defaults will be printed according to the options you specify here.

The jxps and kxps and mxps commands support:

  • -n num: print num copies using PS facilities
  • -o single : do single sided output
  • -o simplex : same as single
  • -o duplex : duplex with long-edge binding (default)
  • -o hduplex : duplex with short-edge binding
  • -o A3 : request A3 paper (mx only)
  • -o manual : use manual feeder
  • -o faceup : do output face-up to side stacker
  • -n : do n-up output (see man psnup)
  • -an : do a2ps -n output (see man a2ps )
The pxps and txps commands support:
  • -n num: print num copies using PS facilities
  • -o single : do single sided output
  • -o simplex : same as single
  • -o duplex : duplex with long-edge binding (default)
  • -o hduplex : duplex with short-edge binding
  • -o trans : request transparencies
  • -o enhance : do enhanced output
  • -o photo : do photo-quality output
  • -n : do n-up output (see man psnup)
  • -an : do a2ps -n output (see man a2ps )

Manual printing on special paper: jx and kx (obsolescent method)

This is useful for when using headed or pre-printed or coloured paper or special weights of paper (consult the printer guide for safe paper-weights to use).

On the jx and kx, use the -o single -o manual options: eg

         jxps -o single -o manual myfile.ps
The printer will print out the header sheet in the normal way, without requiring you to feed your special sheet. When the printer says MANUAL FEED and flashes a red LED, then lower the front panel of the printer and feed in your special sheet of paper in between the manual paper feeder guides. Feed it top-edge first and right-way up. Do not attempt to push it too far: the printer will detect the paper and pick it up nicely. Repeat for any further sheets required.

Don't forget the single option, otherwise your image will appear upside-down on the back, and heavy weights of paper may jam and damage the printer.

Deferred printing

There are some options you can use to achieve deferred printing. You might want to defer printing because it's a large file and will take a long time to print. Or you might have a bunch of short outputs which you want ideally to be printed together a little later, to avoid them being interspersed with other people's output.

These are options for deferred printing:

         lpr -o job-hold-until=when
where when can be:
  • hhmm - this is the GMT time at which to print, up to 24 hours in advance;
  • one of day-time evening night second-shift third-shift weekend indefinite.
    Here day-time is 6am to 6pm, evening and night 6pm to 6am, second-shift from 4pm to midnight, and third-shift from midnight to 8am.
If you prefer to use the kprinter interface, you can set the print-time by clicking on Expand -> Advanced Options -> Schedule printing.

Accounting for billing

Sometimes you may do printing which should be eventually re-charged to a non-PP account, like one of the undergraduate courses.

The kprinter interface provides a way of specifying Billing-information. If necessary, click Options >> to display extra options, and under Advanced Options, enter the Billing information.

Alternatively you can use this on an lpr command:

         lpr -o job-billing=xyz  ......

Printing transparencies from the Windows Terminal Server wts

From your application, choose File / Print and select the px printer, then click Properties and choose the Paper/Quality tab. From this tab, set the Paper Type to Transparency. As an added precaution, set the Paper Tray to Tray 2. Say OK and then print. As Windows remembers your settings, you have to change this back to Paper and Auto next time you print.