Adding a lpd queue
Setting up another print queue under lpd is often reputed to be a difficult task but is in fact delightfully easy.
The LPD printcap file
LPD-based systems use a single configuration file called printcap, which usually resides in /etc. Here is an example:
lp|lp0|0|ps615:\
:lf=/usr/adm/lperr:\
:lp=:\
:rm=ps615:\
:rp=lp:\
:mx#0:\
:sd=/var/spool/lpd0:
lp1|1|ps632a:\
:lf=/usr/adm/lp1err:\
:lp=:\
:mx#0:\
:rm=ps632a:\
:rp=ps632a:\
:sd=/var/spool/lpd1:
lp2|2|ps6m36:\
:lf=/usr/adm/lp2err:\
:lp=:\
:mx#0:\
:rm=ps6m36:\
:rp=ps6m36:\
:sd=/var/spool/lpd2:
This example is for Tru64 UNIX as used by DEC/Compaq Alpha systems but the printcap file looks much the same for all LPD-based UNIX and Linux systems; this is a fairly simple example with 3 queues and a few basic options whereas other printcap examples may have a lot of options for each printer. The default printer is always lp on LPD-based systems.
Adding the ICTprintservice queue
- To add a new entry for the ICTprintservice mono printer, you first need to create the physical spool directory for the queue.
Creating the spool directory
- On most Linux systems, this will be found under /var/spool/lpd - some systems will use this directory as the spool for the first printer and spool directories for additional print queues might be named /var/spool/lpd0, /var/spool/lpd1, and so on. Other systems may put the individual printer spools under /var/spool/lpd as /var/spool/lpd/lpd0, /var/spool/lpd/lpd1, etc. UNIX systems tend to put the print spools under /usr/spool but somewhat confusingly, they may even put them physically under /var/spool/lpd with a symbolic link to /usr/spool! Check your own system to see exactly how it has been done for existing print queue(s) - it doesn't really matter too much where the spool directory actually is as long as it's on a read/write filesystem and won't be accidentally deleted.
- Assuming your own system has print spool directories in /var/spool which looks a bit like this:
> ls -l /var/spool
total 13
drwxrwsrwt 2 daemon daemon 512 Oct 16 1998 calendar
drwxr-xr-x 4 root system 512 Jan 6 1998 cron
drwxrwxr-x 2 uucp uucp 512 Dec 30 1997 locks
-rw-r--r-- 1 root system 4 Jan 26 17:52 lpd.lock
drwxr-xr-x 2 daemon daemon 512 Nov 9 2000 lpd0
drwxr-xr-x 2 daemon daemon 512 Oct 7 2002 lpd1
drwxr-xr-x 2 daemon daemon 512 Aug 22 2003 lpd2
drwxrwxrwt 2 root mail 512 Dec 30 1997 mail
drwxr-xr-x 2 root system 512 Apr 7 2005 mqueue
drwxrwxr-x 10 uucp uucp 512 Jan 6 1998 uucp
drwxrwxrwx 2 uucp uucp 512 Dec 30 1997 uucppublic
Here there are 3 existing print queues whose spool directories are lpd0, lpd1 and lpd2 respectively. Now think of a suitable name for the new spool directory you will be creating for the ICTprintservice queue - in this example, lpd3 would be the logical choice but ictprintservice-mono would be just as suitable. Now create the spool directory with:
mkdir /var/spool/lpd3
- Now you need to change the permissions of the new spool directory to match whatever user, group and access permissions convention is used on your system. On this example, the printer spool directories are owned by user daemon in group daemon and the permissions are octal 755. The new spool directory you have just created will almost certainly be owned by root in group root with permissions probably correct at octal 755. This new spool will probably work but it's best to stick to the settings used by your particular system - a spool owned by root may give rise to security issues, etc on some systems.
- To change the ownership and permissions settings of your new spool directory so that they match the existing ones, type:
chown daemon:daemon /var/spool/lpd3
chmod 755 /var/spool/lpd3
- remembering to substitute the owner, group and permissions as used on your own system.
Adding the ICTprintservice entry to the /etc/printcap file
- Now you need to add an entry for the new print queue to your /etc/printcap file. First, make a copy of the original in case something goes wrong:
cd /etc
cp printcap printcap_orig
- Now, assuming your existing printcap file looks something like the example above, where you have an error log for each queue in /usr/adm and your spool directories are under /var/spool and you have chosen to call your new print queue by the following synonymous names:
- lp3, 3, ICTprintservice_mono
- now edit your /etc/printcap file and add the following lines:
lp3|3|ICTprintservice_mono:\
:lf=/usr/adm/lp3err:\
:lp=:\
:mx#0:\
:pl#66:\
:pw#80:\
:rm=ictprintservice.cc.ic.ac.uk:\
:rp=ICTprintservice_mono:\
:sd=/var/spool/lpd3:
- remembering to susbtitute your own queue, spool directory and error log names if you have chosen different names. Incidentally, the error log is optional but useful in troublehooting - if you don't want an error log, then omit the whole line beginning with :lf from the printcap file.
- Now save the file and restart the lpd daemon.
Restarting lpd
- Linux systems will often have a script to do this, typically in /etc/init.d/lpd and you can type:
/etc/init.d/lpd restart
- to restart the lpd server. Tru64 UNIX systems will have the script /sbin/rc3.d/S65lpd to stop and then start the lpd daemon (there's no restart option):
/sbin/rc3.d/S65lpd stop; /sbin/rc3.d/S65lpd start
- should do the trick and for some Linux and UNIX systems there are of course the various command line and GUI utilities like Red Hat's chkconfig and printool that can also be used to do this. If you can't figure out how lpd is controlled on your system, one sure way of forcing it to re-read /etc/printcap and add in the new queue is to simply kill it and then restart it; first, find out where the lpd daemon lives and its (PID) process ID:
ps ax | grep lpd | grep -v grep
11320 ?? S 0:00.00 /usr/sbin/lpd
- tells us it's in /usr/sbin with the PID 11320 and
kill 11320; /usr/sbin/lpd
- will then terminate the lpd daemon at PID 11320 and then start /usr/sbin/lpd again. In theory, on most UNIX/Linux systems you can also use the lpc command:
lpc restart all
- but in practice some lpc implementations don't restart the master pld daemon, only the daemons serving individual print queues so it's not always a very reliable way of doing this.
- Now you can go to the ICTprintservice printer of your choice and if all is well, print the test page.
It didn't work - no documents were waiting for me at the printer
- If you are unable to retrieve your print copy, make sure that the username you are logged in as on your computer is a valid college username for which you have the correct, matching ID swipe card. You may have more than one computer account on your system for which only one is linked to your college ID, or you are using a private machine or research cluster whose usernames do not match the college-wide usernames. In that case you will not be able to print to the ICTprintservice printers unless your login account is altered or another one set up with a username that matches your primary college username.
Andy Thomas
UNIX/Linux support,
Faculty of Natural Sciences
last updated: 27.01.2006