Topics Map > University of Chicago > IT Services > Applications, Operating Systems, & Devices

Basic Unix - Printing Files

This article describes printing commands in the Unix operating system.

Eventually you will want hard copy from Unix. You may want to print a program you have written so that you can debug it more easily, or to save a long piece of mail and read it on paper, or to produce a perfectly formatted paper or article. (To print a manual page, see Printing man pages in Basic Unix - Learning More.) Files created on home.uchicago.edu can be printed on any of a number of public Apple LaserWriters, using the enscript and lpr commands.

Residence-hall printer codes are as follows (all followed by "lw1"): Burton-Judson, bj; Blackstone, bs; Breckinridge, br; Broadview, bv; Max Mason, mm; New Graduate, ng; Pierce Tower, pt; Shoreland, sl; Snell/Hitchcock, sh; Woodward Court, wc.

Printing: lpr, enscript

The most basic Unix printing command is `lpr'. To print a text file named "myfile" on "printername," type:

 > lpr -Pusprinter myfile

If you are going to print several files in one session, you may wish to type

> setenv PRINTER usprinter

to set the printer for the rest of your session; you will not need to specify it again until the next time you log in. (You can also include the line above in your .login or .cshrc file, so it will be set every time you log in. For more information on .login and .cshrc files, see Appendix E, ".login and .cshrc files".)

Though the standard way to print from some Unix systems is via the `lpr' command, for systems with GNU enscript installed a more flexible way to print is available:

> enscript -Pprintername boring.txt

This will print the file "boring.txt" on the printer "printername". (In this example, you could have skipped the -P option if you'd already set your printer using 'setenv PRINTER printername'.)

Besides the printer, you may specify fonts, headings, some formatting, and spooling options. For example,

> enscript -2rPprintername boring.c

prints a two-column landscape (wide-page) listing of the program file "boring.c" on printername.

Header options to enscript include "-G" for "gaudy" mode, which prints headings, dates, and page numbers in a flashy style; "-B" to omit headers; and "-b header" to specify a header (the default is to show the file name, date last modified, and a page number). To specify a font for the body of the page (the default is Courier10, or Courier 7 in -2r mode), use "-f fontname"; a good small proportional font is Times-Roman 8.

Handling printer queues: lpq, lprm

You can check the queue of files waiting to be printed from the machine you're logged into by typing

> lpq -P printername

You won't need to name the printer if you have issued a "setenv PRINTER printername" command, but you must specify a printer either on the command line or via a `setenv' command.

If you have made a mistake, you can remove your print request from the queue by saying

> lprm -P printername jobnumber

Not specifying a job number will cancel your currently active job. (You may not cancel someone else's job.)




Keywords:enscript lpr   Doc ID:16194
Owner:Larry T.Group:University of Chicago
Created:2010-12-08 18:00 CSTUpdated:2015-09-02 13:15 CST
Sites:University of Chicago, University of Chicago - Sandbox
Feedback:  0   0