## 45.8. Printing Over a Network

Sometimes you'd like to be able to print to a printer that's physically attached to another Unix machine. lpd, the print spool daemon, supports this easily.

lpd is configured using the printcap printer capabilities database, generally stored in /etc/printcap. Generally, a local printer is given a line that looks something like this:

>     lp|local line printer:\
>            :lp=/dev/lpt0:\
>            :sd=/var/spool/output/lpd:lf=/var/log/lpd-errs:

The first line sets the printer name, in this case `lp`, and gives it a more descriptive name (`local line printer`) as well. The rest of the lines define various parameters for this printer using a `parameter`=value format. `lp` specifies the printer device -- in this case, /dev/lpt0. `sd` specifies the local spool directory, that is, where lpd will store spooled files while it's working with them. `lf` specifies the log file, where lpd will write error messages and the like for this printer.

To set up a remote printer, all you have to do is provide a remote machine (`rm`) and a remote printer (`rp`) instead of a printer device:

>     rlp|printhost|remote line printer:\
>            :rm=printhost.domain.com:rp=lp:\
>            :sd=/var/spool/output/printhost:lf=/var/log/lpd-errs:

Note that we added another name; since this is the default printer for the host printhost, either `rlp` or `printhost` will work as printer names. We also used a different spool directory, to keep files spooled for printhost separate from local files; this isn't strictly necessary, but it's handy. Don't forget to create this spool directory before trying to spool anything to this printer!

Some network connected printers have lpd-compatible spoolers built in. Talking to one of these printers is just as easy; just provide the printer's hostname for `rm`. Generally you won't have to provide `rp` unless the printer supports different printing modes by using different remote printer names, since the default name `lp` is almost always supported by these sorts of printers.

-- DJPH

Copyright © 2003 O'Reilly & Associates. All rights reserved.