Ict-innovation/LPI/108.4

= 108.4 Managing Printers and Printing = Candidates should be able to manage printer queues and user print jobs using CUPS and the LPD compatibility interface

Key Knowledge Areas


 * Basic CUPS configuration (for local and remote printers).
 * Manage user print queues.
 * Troubleshoot general printing problems.
 * Add and remove jobs from configured printer queues.

Introducing CUPS
CUPS (Common Unix Print System) is the standard print system on Linux. The cups server is cupsd ; it listens on port 631 and accepts print jobs using IPP (the Internet Printing Protocol). IPP is layered over HTTP, in the sense that an IPP request is an HTTP request with a specific type of content.



Illustration 108.4-1: CUPS Printing System

The CUPS server handles printer queue management and also provides a web server (also on port 631) that supports a browser-based configuration interface allowing the addition and deletion of printers, printer queue management, and so on.



Figure 108.4-2: CUPS Web Interface: Home Page

CUPS filters

The internal work-flow within cups can be relatively complex:



Figure 108.4-3: Linux Printing Architecture

The front-end of CUPS is the actual server that handles the queuing of print jobs and provides the web-based configuration interface. Beyond that, at the heart of the work-flow are the filters, which provide format conversion from the initial input file (plain text, jpeg image, etc) to the language understood by the actual printer. These filters are based on Ghostscript (a GNU project). They consult PPD (Postscript Printer Description) files which specify the printer's capabilities. The filters are found in (for example) /usr/share/ghostscript.

Ghostscript can also be invoked from the command line with the name gs. This command takes postscript or PDF files as input and generates an output file for a specific printer type. It has a database of printer drivers it can handle (this list is reasonably up to date, for example many USB printers are supported) and converts the postscript directly into PCL for these known models. Run the command gs -h to see a list of supported devices:

CUPS back-ends

CUPS supports a variety of back-ends. The term back-end refers to the technology or protocol used to connect to the printer. The table below gives some examples:

Table: CUPS Back-end Technologies

CUPS printers can be added using the web-based interface. The figure below shows two of several screens in this sequence:



Figure 108.4-4: Adding a Printer - I



Figure 108.4-5: Adding a Printer - II

Printers can also be assigned to classes. This is mainly useful on heavy duty print servers that have several printers of the same type connected. Users send print jobs to a class; CUPS will print them on the first printer that becomes available.

Legacy commands for printing
CUPS replaces two earlier printing systems used in UNIX and Linux. One comes from System V Unix, and the other comes from BSD (Berkeley Software Distribution). These two systems were principally intended for printing of plain text files from the command line (and not, for example, printing of office documents with embedded images from a graphical application such as Open Office). The two systems, whilst conceptually similar, used different commands, different configuration files, and a different protocol to talk to the print server.

For backward compatibility, CUPS provides "work-alike" versions of many of these command-line tools. These include:

When using CUPS, these command submit jobs to the CUPS server which performs its usual filtering and back-end processing.

lp and lpr

The lpr and lp utilities are used to submit jobs to a printer. Note that they use different command options. For example lpr uses the -P flag to specify the printer, lp uses the -d flag.

lpq

A user can monitor the status of print queues with lpq. In the example below, demo-1 is the name of the printer.

lprm

The lprm command is used to delete jobs from the print queue. In the example below we delete job 4 from the demo-1 print queue then redisplay the queue:

lpstat

lpstat displays status information about the current classes, jobs, and printers. When run with no arguments, lpstat will list jobs queued by the current user.

Example:

cupsenable and cupsdisable

These commands are used to enable and disable specified printer queues. cupsdisable stops jobs being taken from the queue and sent to the printer. It does not prevent new jobs being sent to the queue. cupsenable re-starts the servicing of the queue.

accept and reject

These commands are used to enable and disable the filling of specified printer queues. In the example below we use reject to disable the demo-1 queue, then attempt to print a file to it. We then re-enable the printer, and successfully send a job to the queue:

lpadmin

The lpadmin command performs a variety of administrative operations on CUPS printers. For example it can be used to set the default printer. In the command sequence shown below there is initially do default destination set. After running lpadmin, we can print to the default printer by using lpr without specifying a printer name:

lpadmin can also be used to delete CUPS printers. In the example below we first list the available queues, then use lpadmin to remove one of them, then list the queues again:

The following is a partial list of the used files, terms and utilities:


 * CUPS configuration files, tools and utilities
 * /etc/cups
 * lpd legacy interface (lpr, lprm, lpq)

Previous Chapter | Next Chapter