/etc/printcap
the printer description file, or “printer capabilities” database
/var/spool/*
the spool directories (there may be more than one)
/var/spool/*/minfree
this file specifies the minimum free space to leave on the partition containing /var
/dev/lp*
actual line printer devices
/dev/printer
the socket for local requests
/etc/hosts.equiv
lists hosts that are allowed printer access
/etc/hosts.lpd
lists hosts that are allowed printer access, but are administered by hosts other than this print server
/etc/passwd
the users file
/usr/sbin/lpd*
the line printer daemons (services)
/var/spool/output/*
the directories to be used for spooling
To add a print queue to lpd, you must add an entry in /etc/printcap, and create a new spool directory under /var/spool/lpd.
An entry in /etc/printcap looks like this:
# LOCAL djet850 #A comment line for humans
lp|dj|deskjet:\ #Three names for this printer, any of which will be accepted
:sd=/var/spool/lpd/dj:\ #The spooler directory
:mx#0:\ #Maximum print job size: 0 means no max
:lp=/dev/lp0:\ #The device that will print these jobs
:sh: #No cover sheet
LPD is the actual printer daemon.
- It starts at boot time,
- reads the printcap file to find what printers are specified, and
- prints any files left over if the system crashed.
Then it calls (commands):
- listen (for print requests), and
- accept (to transfer files to the spool, display the queue, or remove jobs).
LPD is multi-threaded.
- Remember that threads run in system space, while processes run in user space.
- When LPD gets a print job, it forks a child thread to run it.
- The parent thread continues listening for requests.
Unlike LPD, which is a daemon, lpr is a command. Its format is:
lpr /path/to/file [arguments]
Common arguments are:
-Pqueuename
#There must be no space between -P and the queue name. This forces output to a specific printer.
-h
#Suppress header page
-m [email protected]
#Where to send an email with confirmation
-#num
#Number of copies
-T title
#Title for cover page, if used
Note the interesting fact that if no file is specified, standard input will be printed!
Like lpr, lpq is a command. It’s used to list print jobs in the queue. It lists:
- user’s name
- the print job’s position in the queue
- the file(s) to be printed
- the job’s numeric ID
- the size of the job in bytes
Check a specific printer by using the -P option:
lpq -Pdjet850
Notice that once again there is no space between -P and the printer name. If no printer is specified, the default printer is assumed. A user name or job number may be specified after the -P parameter, to restrict reporting to just that user or job.
The lpc (Line Printer Controller) command looks like this:
lpc [subcommand]
Depending on the subcommand, lpc lets the administrator:
- disable or enable a queue,
- reorder jobs in a queue,
- check a printer’s status, or
- (with no subcommand) go to an lpc> prompt for an interactive session.
Subcommands include:
abort
#To terminate current and subsequent printing. Also useful if the spooler is hung: issue abort followed by start.disable
#Completely stop the specified print queue.down
#Same as disable, but it also logs a message to the printer status file. Subsequent print job attempts return the status message.enable
#Turns a spool back on.exit
#Terminates an interactive session.reread
#Tells LPD to reread its config file.start
#Enables printing and starts spooler for the printer(s) named as arguments to this command.stop
#Stops LPD and disables printing.topq [printer] [jobs]
#Lets you send specific jobs to the top of the queue for the specified printer.up [printer]
#Enables the queue for that printer and starts a new print daemon for that queue.
This command removes print jobs from a spool queue. The default printer is assumed unless you specify one:
lprm
#Stops the default spool queue
lprm -Pdjet850
#Stops jobs for djet850
lprm –
#Stops all your print jobs; stops ALL print jobs if issued by root (or su).
lprm 15
#Stops job 15
lprm <username>
#Stops all print jobs for this user