File:  [NetBSD Developer Wiki] / wikisrc / tutorials / how_to_setup_a_printer_with_lpd.mdwn
Revision 1.2: download - view: text, annotated - select for diffs
Sun Feb 5 07:14:36 2012 UTC (2 years, 2 months ago) by schmonz
Branches: MAIN
CVS tags: HEAD
dos2unix

**Contents**

[[!toc]]

#  Introduction 

The NetBSD guide contains a chapter on [printing](http://www.NetBSD.org/docs/guide/en/chap-print.html). The basic parts of this printing system are the line printer spooler daemon known as [lpd(8)](http://netbsd.gw.com/cgi-bin/man-cgi?lpd+8+NetBSD-current) and the associated tools such as [lpr(1)](http://netbsd.gw.com/cgi-bin/man-cgi?lpr+1+NetBSD-current). Practically all printer-specific configuration is done with a special [printcap(5)](http://netbsd.gw.com/cgi-bin/man-cgi?printcap+5+NetBSD-current) database. This guide will not replicate the information presented in the official guide, but instead tries to offer some examples on how this printing system can be configured with modern printers. 

#  Alternatives 

It appears that the _Common Unix Printing System_ (CUPS) has gradually replaced other more traditional printing systems (see also [[How_to_setup_CUPS_in_NetBSD]]). However, there is still room for [lpd(8)](http://netbsd.gw.com/cgi-bin/man-cgi?lpd+8+NetBSD-current) and friends. If not for anything else, CUPS is relatively complex piece of software with quite bad security record. Some prefer also to always use tools that come with an operating system instead of relying on external packages. 

Configuring and using a printer with [lpd(8)](http://netbsd.gw.com/cgi-bin/man-cgi?lpd+8+NetBSD-current) can be easier than with CUPS, once you wrap your head around it. 

#  Example: HP DeskJet 

The following steps were needed for a low-cost HP DeskJet printer. First two packages were installed: [print/hpijs](http://pkgsrc.se/print/hpijs) and [print/foomatic-filters](http://pkgsrc.se/print/foomatic-filters): 
    
    cd /usr/pkgsrc/print/hpijs
    make install package clean
    cd ../foomatic-filters
    make install package clean
    

The former is essential for high-quality output with HP printers and the latter is convenient. The [print/hpijs](http://pkgsrc.se/print/hpijs)-package contains various _.ppd_-files compressed with [bzip(1)](http://netbsd.gw.com/cgi-bin/man-cgi?bzip+1+NetBSD-current). You need to pick one suitable for your printer and unpack it to a desired location. An example: 
    
    mkdir /etc/print
    cd /etc/print
    cp /usr/pkg/share/ppd/HP-DeskJet_5550-hpijs.ppd.gz .
    gunzip *.gz
    

The next step is to configure the printer using the _/etc/printcap_ file. An example that uses parallel port: 
    
    # This requires the following packages:
    # print/hpijs and print/foomatic-filters.
    #
    lp|hp|HP Deskjet 5550:\
            :lp=/dev/lpt0:\
            :af=/etc/print/HP-DeskJet_5550-hpijs.ppd:\
            :if=/usr/pkg/bin/foomatic-rip:\
            :sd=/var/spool/output/lpd:\
            :lf=/var/log/lpd-errs:\
            :rg=print:\
            :rs=true:\
            :sh:
    

This will use the mentioned filter. The curiously named _foomatic_ Perl script takes PostScript as standard input and generates the printer's [page description language](http://en.wikipedia.org/wiki/Page_description_language) as standard output. This is pretty much all that is needed. For additional parameters in the configuration file, such as limiting the access to a group named _print_, please refer to the manual page, [printcap(5)](http://netbsd.gw.com/cgi-bin/man-cgi?printcap+5+NetBSD-current). 

The final step is to enable the [lpd(8)](http://netbsd.gw.com/cgi-bin/man-cgi?lpd+8+NetBSD-current) daemon. The usual conventions with [rc.conf(5)](http://netbsd.gw.com/cgi-bin/man-cgi?rc.conf+5+NetBSD-current) apply: 
    
    lpd=YES
    lpd_flags="-s"
    

The _-s_ flag tells the daemon to use UNIX domain socket instead of listening on all interfaces. This is probably a good idea if you are not configuring a printing server (in which case you probably already know what you are doing). 

After starting the daemon you should be able to print files from the command line using the [lpr(1)](http://netbsd.gw.com/cgi-bin/man-cgi?lpr+1+NetBSD-current). Printing from GUIs should also work. At least [print/xpdf](http://pkgsrc.se/print/xpdf) and [www/firefox3](http://pkgsrc.se/www/firefox3) were both capable of printing. 

#  Example: HP LaserJet & network 

Before start you have to enable printer daemon in _rc.conf_ file, set: 
    
    lpd=YES
    

To enable printing for HP Laser Jet network printers add into _/etc/printcap_ following: 
    
    
    # HP-4250
    HP-4250:\
            :lp=:sh:sd=/var/spool/lpd/lp:\
    	:rm=192.168.170.193:\
    	:lf=/var/log/lpd-errs:mx#0:
    

Where: HP-4250 is basic name of your printer which you can change per desire. Instead of 192.168.170.193 you should set IP address of your printer. 

Check and create directory path if needed. 

#  See also 

  * [Printing](http://netbsd.org/docs/guide/en/chap-print.html#chap-print-remote)
  * [Sumsing ML-1640](http://wiki.netbsd.se/Samsung_ML-1640_and_NetBSD)
  * [Cups](http://wiki.netbsd.se/How_to_setup_CUPS_in_NetBSD)
  * [Other](http://mail-index.netbsd.org/netbsd-users/1997/07/23/0002.html)


CVSweb for NetBSD wikisrc <wikimaster@NetBSD.org> software: FreeBSD-CVSweb