Printing Linux

lpr – Print a file

Command: lpr -P <spooler name> <filename to print>
Example: To print the file /etc/passwd to the printer laser, enter…
lpr -Plaser /etc/passwd


lpq – View Print Jobs

Command: lpq-P <optional spooler name> <optional
user name>

Example: To view current print jobs for all printers for the current user, enter…
lpq

Example: To view current print jobs for the printer laser only, enter…
lpq -Plaser


lprm – Remove a Print Job

Command: lprm -P<spooler name> <job id> <optional user name>
Examples:
To remove the job 123 for printer laser, enter
lprm -Plaser 123

To remove all print jobs for the printer laser
lprm -Plaser –

Note: The “-” at the end of the command is necessary.
The job can be determined by using the above lpq command.

top of page


lpc – Spooler Manager and Status

lpc is used to display the status of the print spooling system and control the availability. A print queue relates to an individual printer. The spool deamon relates to all printers.

Command Argument Options What it does
?
or help
  • nothing
  • command
  • Displays a short description of each command specified in the argument list, or
  • If no argument is given, a list of the recognized commands
status
  • all
  • printer name
Display the status of daemons and queues on the local machine.
topq
  • printer and
  • jobnumber or
  • user name
Place the jobs in the order listed at the top of the printer queue.
abort
  • all
  • printer name
  • Terminate an active spooling daemon on the local host immediately
  • Disable printing  for the specified printers
clean
  • all
  • printer name
Remove any temporary files, data files, and control files that cannot be printed from the specified printer queue(s) on the local machine.
disable
  • all
  • printer name
  • Turn the specified printer queues off
  • This prevents new printer jobs from being entered into the queue by lpr
  • Opposite of enable
down
  • all
  • printer name
  • + message
  • Turn the specified printer queue off
  • Disable printing
  • Put message in the printer status file. The message doesn’t need to be quoted.
  • This is normally used to take a printer down and let others know why the printer is down and print the status message
  • Opposite of up
enable
  • all
  • printer name
  • Enable spooling on the local queue for the listed printers
  • This will allow new jobs in the spool queue
  • Opposite of disable
up
  • all
  • printer name
  • Enable everything
  • Start a new printer daemon
  • Undoes the effects of down
start
  • all
  • printer name
  • Enable printing
  • Start a spooling daemon for the listed printers.
restart
  • all
  • printer name
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).
stop
  • all
  • printer name
  • Stop a spooling daemon after the current job completes
  • Disable printing
exit or quit Exit from lpc

top of page


/etc/printcap = Spooler Configuration File

The configuration and controls for each printer are stored in /etc/printcap. The spooling system accesses the printcap file every time a print job is issued. Each entry is used to describe one printer.

Name Type Example Description
af str NULL name of accounting file
lf str /var/log/printname error logging file name
lo str lock name of lock file
lp str /dev/lp device name to open for output
sd str /var/spool/lpd spool directory
if str NULL name of text filter which does accounting
rm str NULL machine name for remote printer
rp 0 str “lp” remote printer name argument
ff str `\f’ string to send for a form feed
fo bool false print a form feed when device is opened
sf bool false suppress form feeds
mx# num 1000 maximum file size in BUFSIZ blocks, zero=unlimited
pl num 66 page length in lines
pw num 132 page width in characters
px um 0 page width in pixels horizontal
py num 0 page length in pixels vertical
rg str NULL restricted group. Only members of group allowed access
rs bool false restrict remote users to those with local accounts
rw bool false open the printer device for reading and writing
sc bool false suppress multiple copies
sb bool false short banner (one line only)
sh bool false suppress printing of burst page header
st str status status file name
tr str NULL trailer string to print when queue empties
cf str NULL cifplot data filter
df str NULL tex data filter (DVI format)
gf str NULL graph data filter format
nf str NULL ditroff data filter (device independent troff)
of str NULL name of output filtering program
hl bool false print the burst header pagelast
ic bool false driver supports nonstandard ioctl to indent printout
rf str NULL filter for printing FORTRAN style text files
tf str NULL troff data filter (cat phototypesetter)
vf str NULL raster image filter printer
br num none if lp is a tty, set the baud rate
fc num 0 if lp is a tty, clear flag bits
fs num 0 like `fc’ butset bits

Example printcap entries….

hp8500:\
:rm=hp8500:\
:rp=raw:\
:mx#0:\
:lf=/var/log/hp8500log:\
:sh:\
:sd=/usr/spool/lpd/hp8500:

The above entry represents...
  • print queue name hp8500  (Could be called whatever you want)
  • print device rm=hp8500 (This is a network printer that has an entry in the /etc/hosts file)
  • printer option rp=raw (Send data as is)
  • limit mx#0 (No limit)
  • log file lf=/var/log/hp8500log (One entry written to log file for every print job)
  • suppress print header (banner) sh (no value represents off or no)
  • spool directory sd=/usr/spool/lpd/hp8500 (directory where actual spooled files reside until printed)
lp:\
:rm=hp8500:\
:rp=text:\
:mx#0:\
:lf=/var/log/hp8500log:\
:sh:\
:sd=/usr/spool/lpd/hp8500:

The second entry is a print queue named lp.
It is the same as hp8500 except it sends the data as text instead of raw.

top of page