Print from UNIX Desktop (Math)

Mac, Linux and other operating systems use the Cups printing systemGraphical print apps (like GtkLP) change between releases or differ between OSes, but they can be easy to figure out. The "lpr" set of commands have been fairly stable for the past 20 years. Below are some commands to control print jobs.

Default Printer and Basic Commands

Purpose

Command or command sequence

Set a default printer for your account

lpoptions -dvinp105-cfdl

Print a job, see the queue, remove a job

lpr sample.txt
lpq
lprm 55555

Starting Print Jobs

lpr -Pmath-vinp270d sample.txt

Replace math-vinp270d with the real printer and 'sample.txt' with the file to be printed.

View Printer Queues

lpq -Pmath-vinp314

Deleting Print Jobs

lprm 55555

Replace 5555 with the integer ID of the print job you would like to cancel.

Multiple Pages per Printed Sheet

To print four pages on a single sheet, use the number-up option for lpr.    

lpr -o number-up=4 foobar.ps

Single Side Printing with Duplex Printers

Some printers have duplex attachements so they can print on both sides of paper sheets. By default the duplex option will be used. The lpr can pass an option to make the printer use only one side (aka simplex printing).

lpr -o sides=one-sided -Pmath-vinp270d sample.txt

If the printer has duplex hardware, but is printing single sided, you can set the duplex option.

lpr -o sides=two-sided-long-edge -Pmath-vinp270d sample.txt

Setting the Default Printer

Command Line for Ubuntu Linux or Mac

Open a terminal and run lpoptions -d printername

-or-

add export PRINTER=printername to your ~/.bash_profile (if you use bash for your shell) and restart any shells (or run the export printer command in them).

To check a default printer you can run...

$ cat  ~/.cups/lpoptions
 Default math-vinp011-cl
 $ echo $PRINTER
 math-vinp011-cl

Linux Gnome desktop   

  1. Choose System > Preferences > Hardware > Default Printer. The Printer List window appears.    

  2. Select a printer from the list and click Close.