Printing with LPD

Setting up printing can be frustrating. I find the HOWTO's on lpd to be vague and they never actually walk you through a direct implementation. Add to that the fact that everyone wants to use their own specialized daemon to accomplish the task. So here's a basic setup using our good friend /usr/sbin/lpdwhich is likely to be available on any Linux system you come across. Hopefully it will help you get started, or at least point you on your way.

Assumptions:

Configuration:

  1. Verify you have an lp user with a uid/gid of 4/7 with a home directory of /var/spool/lpd.
  2. Create /etc/printcap

    # Local printer example
    lp|hplaser:sh:mx#0:lp=/dev/lp0:sd=/var/spool/lpd/hplaser:if=/etc/lp-filter:lf=/var/spool/lpd/errors:

    # Network printer example
    hplaser:sh:mx#0:lp=/dev/null:rm=hplaser:rp=hplaser_queue:sd=/var/spool/lpd/hplaser:lf=/var/spool/lpd/errors:


  3. Create the spool directory (/var/spool/lpd/lp1, etc) and give them group ownership for the group 'lp'. Create the empty file /var/spool/lpd/errors.
  4. Test your shiny new printer:

    # Launch the daemon
    /usr/sbin/lpd

    # Start the queues
    /usr/sbin/lpc start all

    # Test the queues
    $ lptest 20 5 | lpr -Plp1

  5. If you will be printing directly from your linux box, create /etc/lp-filter and chmod 555. The two printf codes fix "stair-stepping" problems; the final printf command ejects the page once done. Your mileage may vary; most of your research on the Internet will be done to fine-tune this file. Note: If you are trying to get this set up for printing via Samba, you can usually skip this step entirely -- your Windows clients will provide their own drivers! If you now say, "ahh!", the distinction has dawned on you which perhaps was unclear before... congrats! ;-)

    #!/bin/sh
    # sample /etc/lp-filter
    printf "\033&k2G" && /bin/cat && printf "\033&10H" && printf "\f" && exit 0
    exit 2

Printing with Samba:

If you will be sharing your printers to other boxes via Samba: Don't worry about getting input filters correct or so forth; you won't (probably) need them as the windows clients will use their own drivers. You need to add the following information to smb.conf:

[global]
printing = bsd
load printers = yes
printcap name = /etc/printcap

[printers]
path = /var/spool/samba
printable = yes
writable = no
guest ok = no

This will allow you to export all printers listed in /etc/printcap.

Again, your mileage may vary. Hopefully this small example helps you get started in your search. Even if you don't use FreeBSD, try reading their Printing information at http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/printing.html for more info.