LPRng-HOWTO: 15 Oct 2001 (For LPRng-3.7.9)
Prev | Chapter 4. Print Spooling Tutorial | Next

# 4.3. Setting Up the Tutorial Configuration

The previous section has given a very high level view of printing operations and shown a sample of some printcap files. In order to do experiment with these LPRng facilities, we will need to be able to modify the `printcap` information and try various system configurations.

We will use a series of simple printcap entries during this tutorial. We will assume that the LPRng system is using the `/etc/printcap` file. If your system is configured to use another one, then you can make a symbolic link from `/etc/printcap` or you can simply use your default `printcap` file.

Save the existing `printcap` file and then create a new printcap file with the contents as shown below. You will need to have ROOT (superuser) permissions to change the file and perform some of the maintenance operations.

        h4: {78} # cd /etc
        h4: {79} # mv printcap printcap.orig
        h4: {80} # vi printcap
        #  printcap file contents:
        lp:sd=/var/spool/lpd/%P
         :force_localhost
         :lp=/tmp/lp
        lp2:sd=/var/spool/lpd/%P
         :force_localhost
         :lp=/tmp/lp2
        h4: {81} # #  set permissions so everybody can read file
        h4: {82} # chmod 666 printcap

We save the original `printcap` file and create a new one. We give the file world writable permissions so that later we can modify this file without needing to have root permissions. The `printcap` file has two entries: `lp` and `lp2`. Each print queue on the server needs a spool file to hold print jobs, jobs, and the `:sd` value specifies its location. The `%P` value is replaced with the name of the printer when it is used. In classical BSD operation each host has an lpd print spooler running on the local host (we use localhost in this manual for simplicity). Files were copied to spool directories on the localhost and then then print spooler would send them to the destination, which could be another print spooler. This meant that each localhost machine had to have a print spooler and spool queue directory structure. Management of this becomes very difficult in large organizations. The `force_localhost` forces this mode of operation and means that the lpd server and clients must run on the same host.

We use files for the output devices (`:lp=`) so that we can see easily view the output (and also to save trees). We will also need to have some simple test files. Create the files using the following commands.

        h4: {83} # cp /dev/null /tmp/lp
        h4: {84} # cp /dev/null /tmp/lp2
        h4: {85} # chmod 666  /tmp/lp /tmp/lp2
        h4: {86} # echo hi >/tmp/hi
        h4: {87} # echo there >/tmp/there

We will use a dummy `lpd.perms` file that allows all users to do anything. This is useful for testing, but dangerous in a working environment.

        h4: {88} # #  we modify the lpd.perms to allow an ordinary user to control
        h4: {89} # mv lpd.perms lpd.perms.orig
        h4: {90} # echo "DEFAULT ACCEPT" >lpd.perms
        h4: {91} # chmod 666 lpd.perms

Finally we run `checkpc` to make sure that our printcap is correct and to create the necessary spool directories:

        h4: {92} # checkpc -f -V
        Checking printer 'lp'
         Checking directory: '/var/spool/lp'
           directory '/var'
           directory '/var/spool'
           directory '/var/spool/lp'
         Warning -   changing ownership '/var/spool/lp' to 1/1
           checking 'control.lp' file
           checking 'status.lp' file
           checking 'status' file
           cleaning 'status' file, 0K bytes: no truncation
           checking 'log' file
           cleaning 'log' file, 0K bytes: no truncation
           checking 'acct' file
           cleaning 'acct' file, 0K bytes: no truncation
        Checking printer 'lp2'
          Checking directory: '/var/spool/lp2'
            directory '/var'
          ....
        h4: {93} # lpc reread
        h4: {94} # lpd
        h4: {95} # lpq
        Printer: lp@h4
           Queue: no printable jobs in queue

Checkpc performs consistency checks on the printcap file and spool queue entries. The `checkpc -f` (fix) option will change permissions and create directories and can only be executed by ROOT. Checkpc has other functions as well - you can view printcap information, see default configuration values, and remove junk files from spool queues with it.

The `lpc reread` command sends a request to the lpd server to reread the configuration and printcap information. The lpd command is added as insurance in case your lpd server is not running. The `exit` command restores ordinary user privileges, and the lpq command is used to check that the server is running. Finally, we check to see that the `lpc reread` command is accepted from an ordinary user.

Prev | Home | Next
Sample Printcap Entry | Up | Restoring Original Configuration