Printing on Debian can be handled by one of several pieces of software; the original BSD lpr (line printer) system, a rewrite of this system, called lprNG, and also by CUPS (Common Unix Print System).
In order to use the BSD Print Spooler, you will first need to install it as follows:
debian:~# apt-get install lpr Reading Package Lists... Done Building Dependency Tree... Done The following NEW packages will be installed: lpr 0 packages upgraded, 1 newly installed, 0 to remove and 0 not upgraded. Need to get 0B/93.1kB of archives. After unpacking 237Kb will be used. Selecting previously deselected package lpr. (Reading database ... 6049 files and directories currently installed.) Unpacking lpr (from .../lpr_2000.05.07-4.2_i386.deb) ... Setting up lpr (2000.05.07-4.2) ... Starting printer spooler: lpd. debian:~# _ |
Once installed, you will need to modify the /etc/printcap file to suit your tastes:
debian:~# cat /etc/printcap # /etc/printcap: printer capability database. See printcap(5). # You can use the filter entries df, tf, cf, gf etc. for # your own filters. See /etc/filter.ps, /etc/filter.pcl and # the printcap(5) manual page for further details. lp|Generic dot-matrix printer entry:\ :lp=/dev/lp0:\ :sd=/var/spool/lpd/lp:\ :af=/var/log/lp-acct:\ :lf=/var/log/lp-errs:\ :pl#66:\ :pw#80:\ :pc#150:\ :mx#0:\ :sh: # rlp|Remote printer entry:\ # :lp=:\ # :rm=remotehost:\ # :rp=remoteprinter:\ # :sd=/var/spool/lpd/remote:\ # :mx#0:\ # :sh: |
The default installation has a local printer, attached to your first parallel port (/dev/lp0).
The legend for the two-character entries in the /etc/printcap file are as follows:
Name | Type | Default | Description |
lp | str | /dev/lp | local printer device, or port@host for remote |
sd | str | /var/spool/lpd | spool directory |
af | str | NULL | name of accounting file |
lf | str | /dev/console | error logging file name |
pl | num | 66 | page length (in lines) |
pw | num | 132 | page width (in characters) |
pc | num | 200 | price per foot or page in hundredths of cents |
mx | num | 1000 | max file size (in BUFSIZ blocks); 0=unlimited |
sh | bool | false | suppress printing of burst page header |
There are several more obscure options which are also available, and you can find them in the printcap(5) man page.
The default entry is for a printer called "lp", and which can also be referred to as Generic dot-matrix printer entry.
An extract:
lp|Generic dot-matrix printer entry:\ :lp=/dev/lp0:\ :sd=/var/spool/lpd/lp:\ :af=/var/log/lp-acct:\ :lf=/var/log/lp-errs:\ :pl#66:\ :pw#80:\ :pc#150:\ :mx#0:\ :sh: |
You can use the pipe ("|") symbol to separate as many different names for the same printer as you want.
The print jobs themselves are spooled into a directory called /var/spool/lpd/lp, and are then shipped off to the "/dev/lp0" device.
You can use the following commands to operate the print spooler:
SYNTAX: lpr [ -P printername ] <filename> |
The lpr command is used to submit jobs to the printer. You can optionally specify the printer to use by way of the "-P" switch. Otherwise, you will print to the default printer, lp.
Sending the contents of test.txt to the printer:
debian:~# lpr test.txt debian:~# _ |
SYNTAX: lpq [ -P printername ] |
The "lpq" command queries what's inside the printers queue.
debian:~# lpq lp is ready and printing Rank Owner Job Files Total Size active root 1 test.txt 9 bytes |
Again, you can optionally specify the printer queue to query using the "-P" switch otherwise it defaults to the lp printer.
Here we can see that our previously submitted job is currently being processed. Once it has finished printing, it will disappear from the queue.
SYNTAX: lprm [ -P printername] jobnumber |
The lprm command can be used to remove jobs from the queue. This is useful if there's been a paper jam, or if you suddenly realize you've sent your job to the wrong printer, or similar.
You can find out your print job's id number but inspecting the output of "lpq", as we did above.
debian:~# lpq lp is ready and printing Rank Owner Job Files Total Size active root 1 test.txt 9 bytes debian:~# lprm 1 dfA001debian dequeued cfA001debian dequeued debian:~# lpq no entries |