-->
Previous Table of Contents Next


The /etc/printcap File and Spooling Directories

The /etc/printcap file is consulted by both the user’s print command lpr and the lpd print daemon. It contains information about every printer that is accessible from the Linux machine.

The format of /etc/printcap is straightforward (and similar to the /etc/termcap file for terminal descriptions). The following is an extract from /etc/printcap:


# HP Laserjet

lp|hplj|laserjet-acctng|HP LaserJet 4M in Room 425:\

       :lp=/dev/lp0:\

       :sd=/usr/spool/lp0:\

       :lf=/usr/spool/errorlog:\

       :mx#0:\

       :of=/usr/spool/lp0/hpjlp:\

The first field in each entry is a list of all the allowable names for the printer. These can be used with the environment variables set by a user’s shell or by the system, as well as with options on the lpr command line with a destination printer specified. Valid names are separated by a vertical bar.

Usually, each entry includes at least three names: a short name that is four characters or less (such as hplj); a more complete name with an owner, if necessary (such as laserjet-acctng); and a full, descriptive name with any other information necessary to identify the printer (such as HP LaserJet 4M in Room 425).


Note:  
If a print job is submitted without a destination name, and one can’t be determined from environment variable values, it is routed to the printer lp. Therefore, one of the printers (usually the system default printer) should also have the name lp as part of its identifier.

A comment in the file is shown with a pound symbol (sometimes called a hash mark) as the first character. Following the printer name is a set of two-character parameters and values used by the printer. The format of these entries is always one of the following:

NN A Boolean value
NN=string Set equal to string
NN#number Set not equal to number

When a Boolean value is used (no assignment follows the two-character identifier), the value is set to True (zero return code) by default. If the value of False (non-zero return code) is required, the two-character identifier will not be included in the description.

Most assignments are shown with colons beginning and ending each definition to enhance readability and make the file easier for the print utilities to parse. Null values are valid assignments employed by putting two colons together.

A few of the parameters in the /etc/printcap file are worth highlighting because they are useful for administration purposes. Not all of these parameters might be present in every printer definition in the /etc/printcap file, but most appear:

sd The spool directory
lf The log directory for error messages
af Accounting log file
mx Determines the type of files that can be printed
of Output filter program to be used when printing

All printers should have their own spool directories, usually under the printer name in /usr/spool, such as /usr/spool/hplj. Spool directories are necessary for both remote and local printers. When a new printer is added to the system, the spool directory might have to be created manually (using mkdir). The permissions for the spool directory should be set to 775. The directory must be owned by root or daemon. The group ID should be set to root or daemon, too. In both cases, daemon theoretically is the better ID for user and group, although root will work also.

The error log file can be located anywhere on the system. It can be shared by all printers, if desired, because each log entry includes the name of the printer.

The accounting log file is used to record printouts for systems in which users are charged. If accounting records are not to be used on the system, ignore the entry entirely in the /etc/printcap file. The file can also be used for generating statistics, however. Some heavily used systems may want to have the accounting file for those purposes even when charges are not incurred by the users. An entry is written to the accounting log file after a print job has completed. Account information can be displayed with the Linux pac command. (Use the man pac command to display the man pages for more information about pac.)

The mx character enables you to identify the types of files to be printed. Usually this is set to mx#0, meaning that there are no restrictions on the types of files.

Output filters modify the format of the outgoing file to the printer to fit its requirements. For example, many laser printers can’t handle 66 lines per page, so the output filter repaginates to 60 lines (or whatever the number of lines per page is set to). Sometimes, special codes must be added to force line feeds, font changes, or paper bin selections. All these items are part of the output filter. Several other types of filters are available, but the output filter is the one most commonly encountered.

Within each spool directory, there may be two status files: status and lock. Each file is one line long and can be modified with an editor. These files contain a description of the current state of the printer. They are created and managed by the lpd printer daemon and used by several printer commands for status information.


Previous Table of Contents Next