-->
Previous Table of Contents Next


Adding Printer Devices with mknod

Linux supports both parallel and serial printer devices. Both parallel and serial printers are character mode devices. Unfortunately, most Linux distributions do not have an easy-to-use printer installation and configuration utilities like many UNIX versions. Instead, the printer devices must be created and set up manually.

Parallel printers are referred to as devices lp0, lp1, or lp2, depending on the address of the parallel port they are used with. (The most common is the single parallel port on a PC, which is /dev/lp0.) Valid parallel port devices, their addresses, and their usual equivalents under MS-DOS are as follows:

/dev/lp0 0x03bc LPT1
/dev/lp1 0x0378 LPT2
/dev/lp2 0x0278 LPT3


Note:  
To determine the address of a parallel port, you can use a diagnostic utility (such as DOS’s MSD.EXE). Some BIOS versions display port addresses when the system is booting. If you are unsure, try the ports starting with /dev/lp0 and wait to see whether a printout is possible. The first parallel port on a PC is typically set to address 0x03bc.

Linux uses the mknod (make node) command to create a parallel printer device file. After the device is made, the ownership of the device driver file must be altered to root or daemon.

The following is a command to make a parallel printer device on the first parallel port (/dev/lp0):


mknod -m 620 /dev/lp0 c 6 0

chown root.daemon /dev/lp0

In this example, the file permissions are set to mode 620, the device /dev/lp0 is created, and it is set to be a character mode device with major device number of 6 and a minor device number of 0. Usually, minor device numbers start at 0 and are incremented upward; therefore, because this is the first printer added, the minor device number is set to 0.


Note:  
The ownership root.daemon is a special Linux convention for the daemons run by root. The entry root.daemon does not appear in the /etc/passwd file. This uses a convention that lets the first part of the entry (before the period) indicate the user and the second part (after the period) represent the group.

If a different device is configured, the device name itself must be changed to the device number. For each possible parallel port, the mknod commands are as follows:


mknod -m 620 /dev/lp0 c 6 0

mknod -m 620 /dev/lp1 c 6 1

mknod -m 620 /dev/lp2 c 6 2

In these examples, the minor device numbers have been incremented to correspond to the port number. This is not necessary, but it can help with identification.

After the mknod and chown commands have been issued, it is advisable to manually check to ensure that the ownerships are set properly and that a spool directory has been created. If the spool directory doesn’t exist, you have to create it manually. The permissions and ownership requirements of the spool directory were given earlier in the section “The /etc/printcap File and Spooling Directories.”

Managing Printers with lpc

Printers are controlled through a utility called lpc. The lpc program lets you perform several important functions pertaining to the printers used on your Linux system:

  Display printer status information
  Enable or disable the printer
  Enable or disable the printer queue
  Remove all print requests from a printer’s queue
  Promote a particular print request to the top of the queue
  Make changes to the lpd printer daemon

The lpc program can’t be used for remote printers. It affects only those directly attached and configured on the local machine.


Warning:  
Be warned that lpc is one of the most unpredictable and unreliable programs included with the Linux operating system! It can hang up for no obvious reason, and it can also display erroneous status messages. In some cases, the only way to fix a severely screwed-up printer system is to reset the machine completely!


Previous Table of Contents Next