home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 8 / CDACTUAL8.iso / docs / printing.000 < prev    next >
Encoding:
Text File  |  1996-07-11  |  17.5 KB  |  473 lines

  1.   The Linux Printing Usage HOWTO
  2.   by Mark Komarinski <markk@auratek.com>
  3.   v1.11, 2 February 1996
  4.  
  5.   1.  Introduction
  6.  
  7.   This document describes how to use the line printer spooling system
  8.   provided with the Linux operating system.  This HOWTO is the
  9.   supplementary document to the Linux Printing Setup HOWTO, which
  10.   discusses the installation and setup of the Linux printing system.
  11.   The material presented in this HOWTO should be equally relevent for
  12.   all flavors of the BSD operating system in addition to the Linux
  13.   operating system.
  14.  
  15.   1.1.  Linux Printing HOWTO History
  16.  
  17.   This version of the Linux Printing HOWTO is a complete rewrite of the
  18.   one originally written by Grant Taylor <grant@god.tufts.edu> and Brian
  19.   McCauley <B.A.McCauley@bham.ac.uk>.  I have tried to keep with the
  20.   coverage of material presented by Grant and Brian's HOWTO, but I have
  21.   drastically modified the style of presentation and the depth of
  22.   material covered.  I feel that this makes the HOWTO more complete and
  23.   easier to read.  I can only hope that you agree.
  24.  
  25.   1.2.  Version History
  26.  
  27.   v1.11
  28.  
  29.   ╖  new maintainter!
  30.  
  31.   ╖  Added lpc info
  32.  
  33.   ╖  Added some info for troubleshooting
  34.  
  35.   ╖  A start on printing graphics files!
  36.  
  37.   v1.1
  38.  
  39.   ╖  revised some of the wording
  40.  
  41.   ╖  developed section on PostScript printing
  42.  
  43.   ╖  attempted to clarify some of the examples 8-)
  44.  
  45.   ╖  fleshed the discussion of the basic Linux printing utilities
  46.  
  47.   v1.0
  48.  
  49.   ╖  initial public release of the Printing Usage HOWTO
  50.  
  51.   1.3.  Copyrights and Trademarks
  52.  
  53.   Some names mentioned in this HOWTO are claimed as copyrights and/or
  54.   trademarks of certain persons and/or companies.  These names appear in
  55.   full or initial caps in this HOWTO.
  56.  
  57.   The Linux Printing Usage HOWTO v1.11 (c) 1996 Mark Komarinski.
  58.  
  59.   Unless otherwise stated, Linux HOWTO documents are copyrighted by
  60.   their respective authors. Linux HOWTO documents may be reproduced and
  61.   distributed in whole or in part, in any medium physical or electronic,
  62.   as long as this copyright notice is retained on all copies. Commercial
  63.   redistribution is allowed and encouraged; however, the author would
  64.   like to be notified of any such distributions.
  65.  
  66.   All translations, derivative works, or aggregate works incorporating
  67.   any Linux HOWTO documents must be covered under this copyright notice.
  68.  
  69.   That is, you may not produce a derivative work from a HOWTO and impose
  70.   additional restrictions on its distribution. Exceptions to these rules
  71.   may be granted under certain conditions; please contact the Linux
  72.   HOWTO coordinator at the address given below.
  73.  
  74.   In short, we wish to promote dissemination of this information through
  75.   as many channels as possible. However, we do wish to retain copyright
  76.   on the HOWTO documents, and would like to be notified of any plans to
  77.   redistribute the HOWTOs.
  78.  
  79.   If you have questions, please contact Greg Hankins, the Linux HOWTO
  80.   coordinator, at <gregh@sunsite.unc.edu>. You may finger this address
  81.   for phone number and additional contact information.
  82.  
  83.   1.4.  Downloading the Linux Printing HOWTOs
  84.  
  85.   I recommend that if you want to print a copy of this HOWTO that you
  86.   download the PostScript version.  It is formatted in a fashion that is
  87.   aesthetically appealing and easier to read.  You can get the
  88.   PostScript version from one of the many Linux distribution sites (such
  89.   as SunSITE ``'').
  90.  
  91.   1.5.  Feedback
  92.  
  93.   Questions, comments, or corrections for this HOWTO may be directed to
  94.   <markk@auratek.com>.
  95.  
  96.   1.6.  Acknowledgments
  97.  
  98.   Thanks go out to all of the people who took the time to read the alpha
  99.   version of this HOWTO and respond with many helpful comments and
  100.   suggestions---some of you may see your comments reflected in the
  101.   version.
  102.  
  103.   I would also like to thank Grant and Brian for the loads of
  104.   information that they have given me during the transition of
  105.   authorship.
  106.  
  107.   2.  Printing Under Linux
  108.  
  109.   This section discusses how to print files, examine the print queue,
  110.   remove jobs from the print queue, format files before printing them,
  111.   and configure your printing environment.
  112.  
  113.   2.1.  History of Linux Printing
  114.  
  115.   The Linux printing system---the lp system---is a port of the source
  116.   code written by the Regents of the University of California for the
  117.   Berkeley Software Distribution version of the UNIX operating system.
  118.  
  119.   2.2.  Printing a File Using lpr
  120.  
  121.   By far, the most simplistic way to print in the Linux operating system
  122.   is to send the file to be printed directly to the printing device.
  123.   One way to do this is to use the cat command.  As the root user, one
  124.   could do something like
  125.  
  126.        # cat thesis.txt > /dev/lp
  127.  
  128.   In this case, /dev/lp is a symbolic link to the actual printing
  129.   device---be it a dot-matrix, laser printer, typesetter, or plotter.
  130.   (See ln(1) for more information on symbolic links.)
  131.  
  132.   For the purpose of security, only the root user and users in the same
  133.   group as the print daemon are able to write directly to the printer.
  134.   This is why commands such as lpr, lprm, and lpq have to be used to
  135.   access the printer.
  136.  
  137.   Because of this, users have to use lpr to print a file.  The lpr
  138.   command takes care of all the initial work needed to print the file,
  139.   and then it hands control over to another program, lpd, the line
  140.   printing daemon.  The line printing daemon then tells the printer how
  141.   to print the file.
  142.  
  143.   When lpr is executed, it first copies the specified file to a certain
  144.   directory (the spool directory) where the file remains until lpd
  145.   prints it.  Once lpd is told that there is a file to print, it will
  146.   spawn a copy of itself (what we programmers call forking).  This copy
  147.   will print our file while the original copy waits for more requests.
  148.   This allows for multiple jobs to be queued at once.
  149.  
  150.   The syntax of lpr(1) is a very familiar one,
  151.  
  152.        $ lpr [ options ] [ filename ... ]
  153.  
  154.   If filename is not specified, lpr expects input to come from standard
  155.   input (usually the keyboard, or another program's output).  This
  156.   enables the user to redirect a command's output to the print spooler.
  157.   As such,
  158.  
  159.        $ cat thesis.txt | lpr
  160.  
  161.   or,
  162.  
  163.        $ pr -l60 thesis.txt | lpr
  164.  
  165.   The lpr command accepts several command-line arguments that allow a
  166.   user to control how it works.  Some of the most widely used arguments
  167.   are: -Pprinter specifies the printer to use, -h suppresses printing of
  168.   the burst page, -s creates a symbolic link instead of copying the file
  169.   to the spool directory (useful for large files), and -#num specifies
  170.   the number of copies to print.  An example interaction with lpr might
  171.   be something like
  172.  
  173.        $ lpr -#2 -sP dj thesis.txt
  174.  
  175.   This command will create a symbolic link to the file thesis.txt in the
  176.   spool directory for the printer named dj, where it would be processed
  177.   by lpd.  It would then print a second copy of thesis.txt.
  178.  
  179.   For a listing of all the options that lpr will recognize, see lpr(1).
  180.  
  181.   2.3.  Viewing the Print Queue with lpq
  182.  
  183.   To view the contents of the print queue, use the lpq command.  Issued
  184.   without arguments, it returns the contents of the default printer's
  185.   queue.
  186.  
  187.   The returned output of lpq can be useful for many purposes.
  188.  
  189.        $ lpq
  190.        lp is ready and printing
  191.        Rank   Owner      Job  Files                            Total Size
  192.        active mwf        31   thesis.txt                       682048 bytes
  193.  
  194.   2.4.  Canceling a Print Job Using lprm
  195.  
  196.   Another useful feature of any printing system is the ability to cancel
  197.   a job that has been previously queued.  To do this, use lprm.
  198.  
  199.        $ lprm -
  200.  
  201.   The above command cancels all of the print jobs that are owned by the
  202.   user who issued the command.  A single print job can be canceled by
  203.   first getting the job number as reported by lpq and then giving that
  204.   number to lprm.  For example,
  205.  
  206.        $ lprm 31
  207.  
  208.   would cancel job 31 (thesis.txt) on the default printer.
  209.  
  210.   2.5.  Controlling the lpd program with lpc
  211.  
  212.   The lpc(8) program is used to control the printers that lpd serves.
  213.   you can enable or disable a printer or its queues, rearrange entries
  214.   within a queue, and get a status report on the printers and their
  215.   queues.  Lpc is mostly used in a setup where there are multiple
  216.   printers hanging off one machine.
  217.  
  218.        $ lpc
  219.  
  220.   The above will start the lpc program.  By default, this enters you
  221.   into an interactive mode, and you can begin issuing commands.  The
  222.   other option is to issue an lpc command on the command line.
  223.  
  224.        $ lpc status all
  225.  
  226.   A list of the available commands are in the lpd man page, but here are
  227.   a few of the major commands you'll want to know about.  Any commands
  228.   marked with option can either be a printer name (lp, print, etc) or
  229.   the keyword all, which means all printers.
  230.  
  231.   ╖  disable option -  prevents any new printer job from being entered
  232.  
  233.   ╖  down option - disables all printing on the printer
  234.  
  235.   ╖  enable option - allow new jobs to enter the print queue
  236.  
  237.   ╖  quit (or exit) - leave lpc
  238.  
  239.   ╖  restart option - restarts lpd for that printer
  240.  
  241.   ╖  status option - print status of printer
  242.  
  243.   ╖  up option - enable everything and start a new lpd
  244.  
  245.   3.  Miscellaneous Items
  246.  
  247.   This section discusses some of the miscellaneous things that you may
  248.   want to know about printing under Linux.
  249.  
  250.   3.1.  Formatting Before Printing
  251.  
  252.   Since most ASCII files are not formatted for printing, it is useful to
  253.   format them in some way before they are actually printed.  This may
  254.   include putting a title and page number on each page, setting the
  255.   margins, double spacing, indenting, or printing a file in multiple
  256.   columns.  A common way to do this is to use a print preprocessor such
  257.   as pr.
  258.  
  259.        $ pr +4 -d -h"Ph.D. Thesis, 2nd Draft" -l60 thesis.txt | lpr
  260.  
  261.   In the above example, pr would take the file thesis.txt and skip the
  262.   first three pages (+4), set the page length to sixty lines (-l60),
  263.   double space the output (-d), and add the phrase "Ph.D. Thesis, 2nd
  264.   Draft" to the top of each page (-h).  Lpr would then queue pr's
  265.   output.  See its on-line manual page for more information on using pr.
  266.  
  267.   3.2.  The PRINTER Environment Variables
  268.  
  269.   All of the commands in the Linux printing system accept the -P option.
  270.   This option allows the user to specify which printer to use for
  271.   output.  If a user doesn't specify which printer to use, then the
  272.   default printer will be assumed as the output device.
  273.  
  274.   Instead of having to specify a printer to use every time that you
  275.   print, you can set the PRINTER environment variable to the name of the
  276.   printer that you want to use.  This is accomplished in different ways
  277.   for each shell.  For bash you can do this with
  278.  
  279.        $ PRINTER="printer_name"; export PRINTER
  280.  
  281.   and csh, you can do it with
  282.  
  283.        % setenv PRINTER "printer_name"
  284.  
  285.   These commands can be placed in your login scripts (.profile for bash,
  286.   or .cshrc for csh), or issued on the command-line.  (See bash(1) and
  287.   csh(1) for more information on environment variables.)
  288.  
  289.   3.3.  Printing graphics files
  290.  
  291.   Printing graphics files through a printer usually depends on the kind
  292.   of graphics you're converting, and the kind of printer you want to
  293.   send to. Dot matrix is usually out of the question due to differences
  294.   in the way dot-matrix handles graphics.  Your best bet in this
  295.   situation is to see if your printer is compatable with an Epson or an
  296.   IBM ProPrinter, then convert the graphics file to PostScript, then use
  297.   Ghostscript (see next section) to print the graphics.
  298.  
  299.   If you have a laser printer, things are a bit easier since many are
  300.   compatable with PCL.  This now gives you a few options.  Some programs
  301.   may output directly in PCL.  If not, programs like NetPBM can convert
  302.   into PCL.  Last option is to use ghostscript (see next section).
  303.  
  304.   Your absolutely best option is to install packages like NetPBM and
  305.   Ghostscript then installing a magic filter to process the graphics
  306.   files automagically.
  307.  
  308.   3.4.  Printing PostScript files
  309.  
  310.   Printing PostScript files on a printer that has a PostScript
  311.   interpreter is simple; just use lpr, and the printer will take care of
  312.   all of the details for you.  For those of us that don't have printers
  313.   with PostScript capabilities, we have to resort to other means.
  314.   Luckily, there are programs available that can make sense of
  315.   PostScript, and translate it into a language that most printers will
  316.   understand.  Probably the most well known of these programs is
  317.   Ghostscript.
  318.  
  319.   Ghostscript's responsibility is to convert all of the descriptions in
  320.   a PostScript file to commands that the printer will understand.  To
  321.   print a PostScript file using Ghostscript, you might do something like
  322.  
  323.        $ gs -dSAFER -dNOPAUSE -sDEVICE=deskjet -sOutputFile=|lpr thesis.ps
  324.  
  325.   Notice in the above example that we are actually piping the output of
  326.   Ghostscript to the lpr command by using the -sOutputFile option.
  327.  
  328.   Ghostview is an interface to Ghostscript for the X Window System.  It
  329.   allows you to preview a PostScript file before you print it.
  330.   Ghostview and Ghostscript can both be swiped from ``''.
  331.  
  332.   3.5.  Printing TeX files
  333.  
  334.   One of the easiest ways to print TeX files is to convert them to
  335.   PostScript and then print them using Ghostscript.  To do this, you
  336.   first need to convert them from TeX to a format known as DVI (which
  337.   stands for device-independent). You can do this with the tex(1)
  338.   command.  Then you need to convert the DVI file to a PostScript file
  339.   using dvips.  All of this would look like the following when typed in.
  340.  
  341.        $ tex thesis.tex
  342.        $ dvips thesis.dvi
  343.  
  344.   Now you are ready to print the resulting PostScript file as described
  345.   above.
  346.  
  347.   3.6.  Printing troff formatted files
  348.  
  349.        $ groff -Tascii thesis.tr | lpr
  350.  
  351.   or, if you prefer,
  352.  
  353.   $ groff thesis.tr > thesis.ps
  354.  
  355.   and then print the PostScript file as described above.
  356.  
  357.   4.  Answers to Frequently Asked Questions
  358.  
  359.   Q1.  How do I prevent the staircase effect?
  360.  
  361.   A1.  The staircase effect is caused by the way some printers expect
  362.   lines to be terminated.  Some printers want lines that end with a
  363.   carriage-return/line-feed sequence (DOS-style) instead of the line-
  364.   feed sequence used for UNIX-type systems.  The easiest way to fix this
  365.   is to see if your printer can switch between the two styles
  366.   somehow---either by flipping a DIP switch, or by sending an escape
  367.   sequence at the start of each print job.  To do the latter, you need
  368.   to create a filter (see Q2 and Foster95b).
  369.  
  370.   A quick fix is to use a filter on the command-line.  An example of
  371.   this might be
  372.  
  373.        $ cat thesis.txt | todos | lpr
  374.  
  375.   Q2.  What is a filter?
  376.  
  377.   A2.  A filter is a program that reads from standard input (stdin),
  378.   performs some action on this input, and writes to standard output
  379.   (stdout).  Filters are used for a lot of things, including text
  380.   processing.
  381.  
  382.   Q3.  What is a magic filter?
  383.  
  384.   A3.  A magic filter is a filter that performs an action based on a
  385.   file's type.  For example, if the file is a plain, text file, it would
  386.   simply print the file using the normal methods.  If the file is a
  387.   PostScript file, or any other format, it would print it using another
  388.   method (ghostscript).  Two examples of this is magicfilter and
  389.   APSfilter.  One caveat of these filters is that the appropriate
  390.   programs have to be installed before you install the filter.
  391.  
  392.   5.  Troubleshooting
  393.  
  394.   This section covers some common things that can go wrong with your
  395.   printing system.
  396.  
  397.   If your printer doesn't work:
  398.  
  399.   ╖  Do other print jobs work? (application)
  400.  
  401.   ╖  Is lpd running? (check it using lpc) (print controller)
  402.  
  403.   ╖  Can root send something directly to the printer? (print services)
  404.  
  405.   ╖  Can you print from DOS? (cable/printer problem?)
  406.  
  407.      Answering these questions can help find a solution.
  408.  
  409.   Send other suggestions for this section to <markk@auratek.com>.
  410.  
  411.   6.  References
  412.  
  413.   This is a section of references on the Linux printing system.  I have
  414.   tried to keep the references section of this HOWTO as focused as
  415.   possible.  If you feel that I have forgotten a significant reference
  416.   work, please do not hesitate to contact me.
  417.  
  418.   Before you post your question to a USENET group, consider the
  419.   following:
  420.  
  421.   ╖  Is the printer accepting jobs?  (Use lpc(8) to verify.)
  422.  
  423.   ╖  Is the answer to your question covered in this HOWTO, or the
  424.      Printing Setup HOWTO?
  425.  
  426.   If any of the above are true, you may want to think twice before you
  427.   post your question.  And, when you do finally post to a newsgroup, try
  428.   to include pertinent information.  Try not to just say something like,
  429.   "I'm having trouble with lpr, please help." These types of posts will
  430.   most definitely be ignored by many.  Also try to include the kernel
  431.   version that you're running, how the error occured, and, if any, the
  432.   specific error message that the system returned.
  433.  
  434.      Foster, Matt.  Linux Printing Setup HOWTO
  435.         the supplement to this HOWTO; covers setting up, and configuring
  436.         the print software
  437.  
  438.      Welsh, Matt.  Linux Installation and Getting Started
  439.         an excellent introductory text for the beginning Linux user
  440.  
  441.      On-Line Manual Pages
  442.  
  443.      ╖  cat(1)  concatenate and print files
  444.  
  445.      ╖  dvips(1)  convert a TeX DVI file to PostScript
  446.  
  447.      ╖  ghostview(1)  view PostScript documents using Ghostscript
  448.  
  449.      ╖  groff(1)  front-end for the groff document formatting system
  450.  
  451.      ╖  gs(1)  Ghostscript interpreter/viewer
  452.  
  453.      ╖  lpc(8)  line printer control program
  454.  
  455.      ╖  lpd(8)  line printer spooler daemon
  456.  
  457.      ╖  lpq(1)  spool queue examination program
  458.  
  459.      ╖  lpr(1)  off-line printer
  460.  
  461.      ╖  lprm(1)  remove jobs from the line printer spooling queue
  462.  
  463.      ╖  pr(1)  convert text files for printing
  464.  
  465.      ╖  tex(1)  text formatting and typesetting
  466.  
  467.      USENET newsgroups
  468.  
  469.      ╖  comp.os.linux.*  a plethora of information on Linux
  470.  
  471.      ╖  comp.unix.*  discussions relating to the UNIX operating system
  472.  
  473.