home *** CD-ROM | disk | FTP | other *** search
- <!-- TODO
- - graphics printing
- - fonts
- - mpage
- - lpc(8)
- -->
-
- <!-- The Linux Printing Usage HOWTO
- v1.1 (c) 1995 Matt Foster
- v1.11 (c) 1996 Mark Komarinski
- Last revised 26 Aug 1995
- -->
-
- <!doctype linuxdoc system>
- <article>
- <title>The Linux Printing Usage HOWTO</title>
- <author>by Mark Komarinski <markk@auratek.com></author>
- <date>v1.11, 2 February 1996
-
- <sect>Introduction
- <p>
- This document describes how to use the line printer spooling system provided
- with the Linux operating system. This HOWTO is the supplementary document
- to the Linux Printing Setup HOWTO, which discusses the installation and
- setup of the Linux printing system. The material presented in this HOWTO
- should be equally relevent for all flavors of the BSD operating system in
- addition to the Linux operating system.
-
- <sect1>Linux Printing HOWTO History
- <p>
- This version of the Linux Printing HOWTO is a complete rewrite of the one
- originally written by Grant Taylor <grant@god.tufts.edu> and Brian
- McCauley <B.A.McCauley@bham.ac.uk>. I have tried to keep with the
- coverage of material presented by Grant and Brian's HOWTO, but I have
- drastically modified the style of presentation and the depth of material
- covered. I feel that this makes the HOWTO more complete and easier to
- read. I can only hope that you agree.
-
- <sect1>Version History
- <p>
- v1.11
- <itemize>
- <item>new maintainter!
- <item>Added lpc info
- <item>Added some info for troubleshooting
- <item>A start on printing graphics files!
- </itemize>
-
- v1.1
- <itemize>
- <item>revised some of the wording
- <item>developed section on PostScript printing
- <item>attempted to clarify some of the examples 8-)
- <item>fleshed the discussion of the basic Linux printing utilities
- </itemize>
-
- v1.0
- <itemize>
- <item>initial public release of the Printing Usage HOWTO
- </itemize>
-
- <sect1>Copyrights and Trademarks
- <p>
- Some names mentioned in this HOWTO are claimed as copyrights and/or
- trademarks of certain persons and/or companies. These names appear
- in full or initial caps in this HOWTO.
- <p><p>
- <em>The Linux Printing Usage HOWTO v1.11 (c) 1996 Mark Komarinski.</em>
- <p><p>
- Unless otherwise stated, Linux HOWTO documents are copyrighted by their
- respective authors. Linux HOWTO documents may be reproduced and distributed
- in whole or in part, in any medium physical or electronic, as long as this
- copyright notice is retained on all copies. Commercial redistribution is
- allowed and encouraged; however, the author would like to be notified of any
- such distributions.
-
- <p>
- All translations, derivative works, or aggregate works incorporating
- any Linux HOWTO documents must be covered under this copyright notice.
-
- That is, you may not produce a derivative work from a HOWTO and impose
- additional restrictions on its distribution. Exceptions to these rules
- may be granted under certain conditions; please contact the Linux HOWTO
- coordinator at the address given below.
- <p>
- In short, we wish to promote dissemination of this information through as
- many channels as possible. However, we do wish to retain copyright on the
- HOWTO documents, and would like to be notified of any plans to redistribute
- the HOWTOs.
-
- <p>
- If you have questions, please contact Greg Hankins, the Linux HOWTO
- coordinator, at <gregh@sunsite.unc.edu>. You may finger this address
- for phone number and additional contact information.
-
-
- <sect1>Downloading the Linux Printing HOWTOs
- <p>
- I recommend that if you want to print a copy of this HOWTO that you
- download the PostScript version. It is formatted in a fashion that is
- aesthetically appealing and easier to read. You can get the PostScript
- version from one of the many Linux distribution sites (such as SunSITE
- <ref id="ftp://sunsite.unc.edu/pub/Linux/docs/HOWTO/">).
-
- <sect1>Feedback
- <p>
- Questions, comments, or corrections for this HOWTO may be directed to
- <markk@auratek.com>.
-
- <sect1>Acknowledgments
- <p>
- Thanks go out to all of the people who took the time to read the alpha
- version of this HOWTO and respond with many helpful comments and
- suggestions---some of you may see your comments reflected in the version.
- <p>
- I would also like to thank Grant and Brian for the loads of information
- that they have given me during the transition of authorship.
-
- <sect>Printing Under Linux
- <p>
- This section discusses how to print files, examine the print queue, remove
- jobs from the print queue, format files before printing them, and configure
- your printing environment.
-
- <sect1>History of Linux Printing
- <p>
- The Linux printing system---the <em>lp</em> system---is a port of the source
- code written by the Regents of the University of California for the Berkeley
- Software Distribution version of the UNIX operating system.
-
- <sect1>Printing a File Using <em>lpr</em>
- <p>
- By far, the most simplistic way to print in the Linux operating system is
- to send the file to be printed directly to the printing device. One way
- to do this is to use the <em>cat</em> command. As the <tt>root</tt> user,
- one could do something like
-
- <tscreen><verb>
- # cat thesis.txt > /dev/lp
- </verb></tscreen>
-
- In this case, <tt>/dev/lp</tt> is a symbolic link to the actual printing
- device---be it a dot-matrix, laser printer, typesetter, or plotter. (See
- <em>ln</em>(1) for more information on symbolic links.)
- <p>
- For the purpose of security, only the <tt>root</tt> user and users in the
- same group as the print daemon are able to write directly to the printer.
- This is why commands such as <em>lpr</em>, <em>lprm</em>, and <em>lpq</em>
- have to be used to access the printer.
- <p>
- Because of this, users have to use <em>lpr</em> to print a file. The
- <em>lpr</em> command takes care of all the initial work needed to print
- the file, and then it hands control over to another program, <em>lpd</em>,
- the line printing daemon. The line printing daemon then tells the printer
- how to print the file.
- <p>
- When <em>lpr</em> is executed, it first copies the specified file to a
- certain directory (the spool directory) where the file remains until
- <em>lpd</em> prints it. Once <em>lpd</em> is told that there is a file to
- print, it will spawn a copy of itself (what we programmers call forking).
- This copy will print our file while the original copy waits for more
- requests. This allows for multiple jobs to be queued at once.
- <p>
- The syntax of <em>lpr</em>(1) is a very familiar one,
-
- <tscreen><verb>
- $ lpr [ options ] [ filename ... ]
- </verb></tscreen>
-
- If <tt>filename</tt> is not specified, <em>lpr</em> expects input to come
- from standard input (usually the keyboard, or another program's output).
- This enables the user to redirect a command's output to the print spooler.
- As such,
-
- <tscreen><verb>
- $ cat thesis.txt | lpr
- </verb></tscreen>
-
- or,
-
- <tscreen><verb>
- $ pr -l60 thesis.txt | lpr
- </verb></tscreen>
-
- The <em>lpr</em> command accepts several command-line arguments that allow a
- user to control how it works. Some of the most widely used arguments are:
- -<bf/P/printer specifies the printer to use, -<bf/h/ suppresses printing of
- the burst page, -<bf/s/ creates a symbolic link instead of copying the file
- to the spool directory (useful for large files), and -<bf/#/num
- specifies the number of copies to print. An example interaction with
- <em>lpr</em> might be something like
-
- <tscreen><verb>
- $ lpr -#2 -sP dj thesis.txt
- </verb></tscreen>
-
- This command will create a symbolic link to the file <tt>thesis.txt</tt> in
- the spool directory for the printer named <em>dj</em>, where it would be
- processed by <em>lpd</em>. It would then print a second copy of
- <tt>thesis.txt</tt>.
- <p>
- For a listing of all the options that <em>lpr</em> will recognize, see
- <em>lpr</em>(1).
-
- <sect1>Viewing the Print Queue with <em>lpq</em>
- <p>
- To view the contents of the print queue, use the <em>lpq</em> command.
- Issued without arguments, it returns the contents of the default printer's
- queue.
- <p>
- The returned output of <em>lpq</em> can be useful for many purposes.
-
- <tscreen><verb>
- $ lpq
- lp is ready and printing
- Rank Owner Job Files Total Size
- active mwf 31 thesis.txt 682048 bytes
- </verb></tscreen>
-
- <sect1>Canceling a Print Job Using <em>lprm</em>
- <p>
- Another useful feature of any printing system is the ability to cancel a job
- that has been previously queued. To do this, use <em>lprm</em>.
-
- <tscreen><verb>
- $ lprm -
- </verb></tscreen>
-
- The above command cancels all of the print jobs that are owned by the user
- who issued the command. A single print job can be canceled by first getting
- the job number as reported by <em>lpq</em> and then giving that number to
- <em>lprm</em>. For example,
-
- <tscreen><verb>
- $ lprm 31
- </verb></tscreen>
-
- would cancel job 31 (<tt>thesis.txt</tt>) on the default printer.
-
- <sect1>Controlling the lpd program with <em>lpc</em>
- <p>
- The <em>lpc</em>(8) program is used to control the printers that lpd serves.
- you can enable or disable a printer or its queues, rearrange entries within
- a queue, and get a status report on the printers and their queues.
- Lpc is mostly used in a setup where there are multiple printers hanging off
- one machine.
-
- <tscreen><verb>
- $ lpc
- </verb></tscreen>
-
- The above will start the lpc program. By default, this enters you into
- an interactive mode, and you can begin issuing commands. The other option
- is to issue an lpc command on the command line.
-
- <tscreen><verb>
- $ lpc status all
- </verb></tscreen>
-
- A list of the available commands are in the <em>lpd</em> man page, but here
- are a few of the major commands you'll want to know about. Any commands
- marked with <em>option</em> can either be a printer name (lp, print, etc) or
- the keyword <tt>all</tt>, which means all printers.
-
- <itemize>
- <item> disable <em>option</em> - prevents any new printer job from being entered
- <item> down <em>option</em> - disables all printing on the printer
- <item> enable <em>option</em> - allow new jobs to enter the print queue
- <item> quit (or exit) - leave lpc
- <item> restart <em>option</em> - restarts lpd for that printer
- <item> status <em>option</em> - print status of printer
- <item> up <em>option</em> - enable everything and start a new lpd
- </itemize>
-
- <sect>Miscellaneous Items
- <p>
- This section discusses some of the miscellaneous things that you may
- want to know about printing under Linux.
-
- <sect1>Formatting Before Printing
- <p>
- Since most ASCII files are not formatted for printing, it is useful to
- format them in some way before they are actually printed. This may include
- putting a title and page number on each page, setting the margins, double
- spacing, indenting, or printing a file in multiple columns. A common way to
- do this is to use a print preprocessor such as <em>pr</em>.
-
- <tscreen><verb>
- $ pr +4 -d -h"Ph.D. Thesis, 2nd Draft" -l60 thesis.txt | lpr
- </verb></tscreen>
-
- In the above example, <em>pr</em> would take the file <tt>thesis.txt</tt>
- and skip the first three pages (+4), set the page length to sixty lines
- (-l60), double space the output (-d), and add the phrase "Ph.D. Thesis, 2nd
- Draft" to the top of each page (-h). <em>Lpr</em> would then queue
- <em>pr</em>'s output. See its on-line manual page for more information on
- using <em>pr</em>.
-
- <sect1>The PRINTER Environment Variables
- <p>
- All of the commands in the Linux printing system accept the -<bf/P/ option.
- This option allows the user to specify which printer to use for output. If
- a user doesn't specify which printer to use, then the default printer will
- be assumed as the output device.
- <p>
- Instead of having to specify a printer to use every time that you print, you
- can set the PRINTER environment variable to the name of the printer that you
- want to use. This is accomplished in different ways for each shell. For
- <em>bash</em> you can do this with
-
- <tscreen><verb>
- $ PRINTER="printer_name"; export PRINTER
- </verb></tscreen>
-
- and <em>csh</em>, you can do it with
-
- <tscreen><verb>
- % setenv PRINTER "printer_name"
- </verb></tscreen>
-
- These commands can be placed in your login scripts (.profile for <em>bash</em>,
- or .cshrc for <em>csh</em>), or issued on the command-line. (See
- <em>bash</em>(1) and <em>csh</em>(1) for more information on environment
- variables.)
-
- <sect1>Printing graphics files
- <p>
-
- Printing graphics files through a printer usually depends on the kind of
- graphics you're converting, and the kind of printer you want to send to. Dot
- matrix is usually out of the question due to differences in the way
- dot-matrix handles graphics. Your best bet in this situation is to see if
- your printer is compatable with an Epson or an IBM ProPrinter, then convert
- the graphics file to PostScript, then use Ghostscript (see next section) to
- print the graphics.
- <p>
- If you have a laser printer, things are a bit easier since many are
- compatable with PCL. This now gives you a few options. Some programs may
- output directly in PCL. If not, programs like <em>NetPBM</em> can convert
- into PCL. Last option is to use ghostscript (see next section).
- <p>
- Your absolutely best option is to install packages like NetPBM and Ghostscript
- then installing a magic filter to process the graphics files automagically.
-
- <sect1>Printing PostScript files
- <p>
- Printing PostScript files on a printer that has a PostScript interpreter
- is simple; just use <em>lpr</em>, and the printer will take care of all
- of the details for you. For those of us that don't have printers with
- PostScript capabilities, we have to resort to other means. Luckily, there
- are programs available that can make sense of PostScript, and translate
- it into a language that most printers will understand. Probably the most
- well known of these programs is Ghostscript.
- <p>
- Ghostscript's responsibility is to convert all of the descriptions in a
- PostScript file to commands that the printer will understand. To print
- a PostScript file using Ghostscript, you might do something like
-
- <tscreen><verb>
- $ gs -dSAFER -dNOPAUSE -sDEVICE=deskjet -sOutputFile=|lpr thesis.ps
- </verb></tscreen>
-
- Notice in the above example that we are actually piping the output of
- Ghostscript to the <em>lpr</em> command by using the -<bf/sOutputFile/
- option.
-
- Ghostview is an interface to Ghostscript for the X Window System. It allows
- you to preview a PostScript file before you print it. Ghostview and
- Ghostscript can both be swiped from <ref
- id="ftp://prep.ai.mit.edu/pub/gnu/">.
-
- <sect1>Printing TeX files
- <p>
- One of the easiest ways to print TeX files is to convert them to PostScript
- and then print them using Ghostscript. To do this, you first need to
- convert them from TeX to a format known as DVI (which stands for
- device-independent). You can do this with the <em>tex</em>(1) command. Then
- you need to convert the DVI file to a PostScript file using <em>dvips</em>.
- All of this would look like the following when typed in.
-
- <tscreen><verb>
- $ tex thesis.tex
- $ dvips thesis.dvi
- </verb></tscreen>
-
- Now you are ready to print the resulting PostScript file as described above.
-
- <sect1>Printing <tt>troff</tt> formatted files
- <p>
-
- <tscreen><verb>
- $ groff -Tascii thesis.tr | lpr
- </verb></tscreen>
-
- or, if you prefer,
-
- <tscreen><verb>
- $ groff thesis.tr > thesis.ps
- </verb></tscreen>
-
- and then print the PostScript file as described above.
-
- <sect>Answers to Frequently Asked Questions
- <p><p>
- Q1. How do I prevent the staircase effect?
- <p>
- A1. The staircase effect is caused by the way some printers expect lines to
- be terminated. Some printers want lines that end with a
- carriage-return/line-feed sequence (DOS-style) instead of the line-feed
- sequence used for UNIX-type systems. The easiest way to fix this is to see
- if your printer can switch between the two styles somehow---either by
- flipping a DIP switch, or by sending an escape sequence at the start of each
- print job. To do the latter, you need to create a filter (see Q2 and
- [Foster95b]).
-
- A quick fix is to use a filter on the command-line. An example of this
- might be
-
- <tscreen><verb>
- $ cat thesis.txt | todos | lpr
- </verb></tscreen>
-
- <p>
- Q2. What is a filter?
- <p>
- A2. A filter is a program that reads from standard input (<em>stdin</em>),
- performs some action on this input, and writes to standard output
- (<em>stdout</em>). Filters are used for a lot of things, including text
- processing.
- <p><p>
- Q3. What is a <em>magic</em> filter?
- <p>
- A3. A magic filter is a filter that performs an action based on a file's
- type. For example, if the file is a plain, text file, it would simply print
- the file using the normal methods. If the file is a PostScript file, or any
- other format, it would print it using another method (ghostscript). Two
- examples of this is magicfilter and APSfilter. One caveat of these filters
- is that the appropriate programs have to be installed before you install
- the filter.
-
- <sect>Troubleshooting
- <p>
- This section covers some common things that can go wrong with your printing
- system.
- <p>
- If your printer doesn't work:
- <itemize>
- <item>Do other print jobs work? (application)
- <item>Is lpd running? (check it using lpc) (print controller)
- <item>Can root send something directly to the printer? (print services)
- <item>Can you print from DOS? (cable/printer problem?)
- </itemize>
- Answering these questions can help find a solution.
-
- Send other suggestions for this section to <markk@auratek.com>.
-
- <sect>References
- <p>
- This is a section of references on the Linux printing system. I have
- tried to keep the references section of this HOWTO as focused as
- possible. If you feel that I have forgotten a significant reference
- work, please do not hesitate to contact me.
- <p>
- Before you post your question to a USENET group, consider the following:
- <itemize>
- <item>Is the printer accepting jobs? (Use <em>lpc</em>(8) to verify.)
- <item>Is the answer to your question covered in this HOWTO, or the Printing
- Setup HOWTO?
- </itemize>
- <p>
- If any of the above are true, you may want to think twice before you post
- your question. And, when you do finally post to a newsgroup, try to include
- pertinent information. Try not to just say something like, "I'm having
- trouble with lpr, please help." These types of posts will most definitely be
- ignored by many. Also try to include the kernel version that you're
- running, how the error occured, and, if any, the specific error message that
- the system returned.
-
- <descrip>
- <tag>Foster, Matt. <em>Linux Printing Setup HOWTO</em></tag> the supplement
- to this HOWTO; covers setting up, and configuring the print software
- <p>
- <tag>Welsh, Matt. <em>Linux Installation and Getting Started</em></tag> an
- excellent introductory text for the beginning Linux user
- <p>
- <tag>On-Line Manual Pages</tag>
- <itemize>
- <item><em>cat</em>(1) concatenate and print files
- <item><em>dvips</em>(1) convert a TeX DVI file to PostScript
- <item><em>ghostview</em>(1) view PostScript documents using Ghostscript
- <item><em>groff</em>(1) front-end for the groff document formatting system
- <item><em>gs</em>(1) Ghostscript interpreter/viewer
- <item><em>lpc</em>(8) line printer control program
- <item><em>lpd</em>(8) line printer spooler daemon
- <item><em>lpq</em>(1) spool queue examination program
- <item><em>lpr</em>(1) off-line printer
- <item><em>lprm</em>(1) remove jobs from the line printer spooling queue
- <item><em>pr</em>(1) convert text files for printing
- <item><em>tex</em>(1) text formatting and typesetting
- </itemize>
- <p>
- <tag>USENET newsgroups</tag>
- <itemize>
- <item><tt>comp.os.linux.*</tt> a plethora of information on Linux
- <item><tt>comp.unix.*</tt> discussions relating to the UNIX operating system
- </itemize>
- </descrip>
- </article>
-