Make your own free website on

Printing in Linux

To set up a printer in Linux, all you need to do is specify the device file to use and to set the printer configuration options in the printcap file, providing that you have parallel port support compiled into your kernel.  If you don't have parallel port support in you kernel obtain the latest kernel and compile it.  lp0 will be the corresponding device name for the LPT1 parallel port on your system.  Usually there are three names for parallel ports, you can see them in the /dev directory.

   suse:/dev #ls -lah /dev/lp*
   crw-rw----   1 root     lp         6,   0 Nov  8  1999 /dev/lp0
   crw-rw----   1 root     lp         6,   1 Nov  8  1999 /dev/lp1
   crw-rw----   1 root     lp         6,   2 Nov  8  1999 /dev/lp2
The c at the beginning of the file permissions denotes that it is a character device.

Printcap File

EXAMPLE /etc/printcap
   lp|lp2|laserjet-letter-auto-mono-300|laserjet letter auto mono 300:\
OPTIONS for /etc/printcap

line 1, names for the printer separated by a pipe |, one of the names should be lp as lpr will use it as a default.

line 2, is the device to open for output

line 3, specifies the spool directory

line 4, error logging filename

line 5, name of the accounting file

line 6, name of text filter that does accounting

line 7, sets maximum file size, 0 for unlimited

line 8, trailer string to print when queue empties

The first field of each entry starts at the left margin and contains a list of names for the printer, each is separated by a '|'.  Subfield entries are defined on a single logical line with the '\' used to suppress the newline.  Fields are separated by ':'.

lpc - line printer control program

   lpc [command [argument ...]]

Lpc is used by the system administrator to control the operation of the line printer system. For each line printer configured in /etc/printcap, lpc may be used to:

  • disable or enable a printer,
  • disable or enable a printer's spooling queue,
  • rearrange the order of jobs in a spooling queue,
  • find the status of printers, and their associated spooling queues and printer dameons.
lpc Commands:
Print a short description of each command specified in the argu ment list, or, if no arguments are given, a list of the recog nized commands.
abort { all | printer }
Terminate an active spooling daemon on the local host immediately and then disable printing (preventing new daemons from being started by lpr) for the specified printers.
clean { all | printer }
Remove any temporary files, data files, and control files that cannot be printed (i.e., do not form a complete printer job) from the specified printer queue(s) on the local machine.
disable { all | printer }
Turn the specified printer queues off. This prevents new printer jobs from being entered into the queue by lpr.
down { all | printer } message ...
Turn the specified printer queue off, disable printing and put message in the printer status file. The message doesn't need to be quoted, the remaining arguments are treated like echo(1). This is normally used to take a printer down and let others know why lpq(1) will indicate the printer is down and print the status message).
enable { all | printer }
Enable spooling on the local queue for the listed printers. This will allow lpr(1) to put new jobs in the spool queue.
exit quit
Exit from lpc.
restart { all | printer }
Attempt to start a new printer daemon. This is useful when some abnormal condition causes the daemon to die unexpectedly leaving jobs in the queue. Lpq will report that there is no daemon present when this condition occurs. If the user is the super-user, try to abort the current daemon first (i.e., kill and restart a stuck daemon).
start { all | printer }
Enable printing and start a spooling daemon for the listed printers.
status { all | printer }
Display the status of daemons and queues on the local machine.
stop { all | printer }
Stop a spooling daemon after the current job completes and disable printing.
topq printer [ jobnum ... ] [ user ... ]
Place the jobs in the order listed at the top of the printer queue.
up { all | printer }
Enable everything and start a new printer daemon. Undoes the effects of down.

lpd - line printer spooler daemon

   lpd [-l] [port#]

Lpd is the line printer daemon (spool area handler) and is normally invoked at boot time from the rc file. It makes a single pass through the printcap file to find out about the existing printers and prints any files left after a crash. It then uses the system calls listen and accept to receive requests to print files in the queue, transfer files to the spooling area, display the queue, or remove jobs from the queue. In each case, it forks a child to handle the request so the parent can continue to listen for more requests.

lpr - off line print

   lpr [-Pprinter] [-#num] [-C class] [-J job] [-T title] [-U user] [-i [numcols]]
       [-1234 font] [-wnum] [-cdfghlnmprstv] [name ...]

Lpr uses a spooling daemon to print the named files when facilities become available. If no names appear, the standard input is assumed. If you try to spool too large a file, it will be truncated. Lpr will object to printing binary files. If a user other than root prints a file and spooling is disabled, lpr will print a message saying so and will not put jobs in the queue.

-#num  The quantity num is the number of copies desired of each file named. For example,

   lpr -#3 file1.txt file2.txt file3.txt
   would result in 3 copies of the file file1.txt, followed by 3 copies of the file file2.txt, etc.

lpq - spool queue examination program

   lpq [-l] [-Pprinter] [job # ...] [user ...]

Lpq examines the spooling area used by lpd for printing files on the line printer, and reports the status of the specified jobs or all jobs associated with a user. Lpq invoked without any arguments reports on any jobs currently in the queue. Due to the dynamic nature of the information in the spooling directory lpq may report unreliably. Output formatting is sensitive to the line length of the terminal; this can results in widely spaced columns.

Specify a particular printer, otherwise the default line printer is used (or the value of the PRINTER variable in the environment). All other arguments supplied are interpreted as user names or job numbers to filter out only those jobs of interest.
Information about each of the files comprising the job entry is printed. Normally, only as much information as will fit on one line is displayed.

lprm - remove jobs from the line printer spooling queue

   lprm [-Pprinter] [-] [job # ...] [user ...]

Lprm will remove a job, or jobs, from a printer's spool queue. Since the spooling directory is protected from users, using lprm is normally the only method by which a user may remove a job. The owner of a job is determined by the user's login name and host name on the machine where the lpr command was invoked.

Specify the queue associated with a specific printer (otherwise the default printer is used).
If a single `-' is given, lprm will remove all jobs which a user owns. If the super-user employs this flag, the spool queue will be emptied entirely.
Causes lprm to attempt to remove any jobs queued belonging to that user (or users). This form of invoking lprm is useful only to the super-user.
job #
A user may dequeue an individual job by specifying its job number. This number may be obtained from the lpq(1) program

If neither arguments or options are given, Lprm will delete the currently active job if it is owned by the user who invoked lprm. Lprm announces the names of any files it removes and is silent if there are no jobs in the queue which match the request list. Lprm will kill off an active daemon, if necessary, before removing any spooling files. If a daemon is killed, a new one is automatically restarted upon completion of file removals.

"Permission denied" is displayed if the user tries to remove files other than his own.