Differences between revisions 11 and 12
Revision 11 as of 2016-10-09 12:42:02
Size: 25525
Editor: Brian Potkin
Comment: Wrote Non-Free Printer Drivers and Firmware. Added some links.
Revision 12 as of 2016-10-09 19:05:22
Size: 27890
Editor: Brian Potkin
Comment: Added section on device-uris for a networked printer.
Deletions are marked like this. Additions are marked like this.
Line 113: Line 113:
<<Anchor(networkuri)>>
=== The device-uri for a Networked Printer ===

CUPS can use at least one of the !AppSocket, Internet Printing (IPP) and Line Printer (LPD) protocols for connecting to printers and print servers over a network connection.

 * '''!AppSocket'''

Also known as the ''!JetDirect'' or ''RAW'' protocol, it is the most basic protocol that can be supported. The URI scheme is

{{{
socket://<ip_address_or_hostname>:<port_number>
}}}

The standard port number is 9100 and this will be used by default if it is omitted from the device_uri. Print servers with three outputs would require three port numbers; for example, 9100, 9101 and 9102.

It is questionable whether ''!AppSocket'' is a protocol. There is no specified standard for it; no queue management; no aborting of jobs; no querying of printer supplies; no encryption. All it does is shovel the data for a print-ready file over the network and then close the connection. Because the only overhead is TCP/IP the data transfer is generally fast. Also, it has been in widespread use for a long time so the printer implementations of !AppSocket are good.

 * '''IPP'''

Printing normally takes place over port 631 with the URI being

{{{
ipp://<ip_address_or_hostname>:<port_number>/<resource>
}}}

Unfortunately, the ''resource'' path has never been standardised and it may require some experimentation to determine what a printer or server will accept. Apparently, newer printers use ''/ipp/print'' in the path but for older products it could be something entirely different. Maybe the printer's front panel or

{{{
/usr/lib/cups/backend/snmp <ip_address>
}}}

will help. A CUPS server can be reached with

{{{
ipp://<ip_address_or_hostname>/printers/<print_queue_name>
}}}

In theory, the handshaking and status monitoring done by the ''IPP'' protocol should ensure reliable printing but, in practice, there are printers which do not implement some aspects of ''IPP'' very well.

 * '''LPD'''

This is the original network protocol with a URI of

{{{
lpd://<ip_address_or_hostname>/<print_queue_name>
}}}

The default port used is 515. CUPS has limited functionality for ''LPD''-based clients but, even though !AppSocket and IPP are [[https://www.cups.org/doc/network.html|seen as better alternatives]], it is regarded as a reliable protocol.

Translation(s): nonef


Setting up and administering print queues within the CUPS printing system.

A document destined for a printer is frequently called a print job. On its way to the printer it is first put into a queue before being processed. The queue has certain properties which determine how the print job is dealt with and may be queried with lpoptions and lpstat for a list of some of these properties and the queue status repectively.

The properties specified when the queue is created are not immutable. Quite a few of them can be altered by a user when the print job is submitted to the queue. An administrator who hoped to confine users to duplex (two-sided) printing with two pages per sheet of paper would have to look outside the CUPS framework for a solution to add to the system.

Several queues can point to the same physical device, the printer, but it is very common for "print queue" and "printer" to be used interchangably. Generally no harm comes from this.

The device-uri

Ultimately, a print job has to go somewhere. Most users expect the "somewhere" to be a printer. To see which "somewhere"s you have open to you, do (as root or a user):

  /usr/sbin/lpinfo -v

The backends in /usr/lib/cups/backends are now used in discovery mode in an endeavour to locate printers. Here is the output of one such command when two printers are attached to the machine via a USB and parallel port and one is available over the network:

  network ipps
  network http
  network lpd
  network ipp14
  network socket
  network https
  direct parallel:/dev/lp0
  network ipp
  serial serial:/dev/ttyS0?baud=115200
  serial serial:/dev/ttyS1?baud=115200
  direct usb://EPSON/Stylus%20COLOR%20740
  network dnssd://TEST1%20%40%20wheezy._ipp._tcp.local/cups
  network dnssd://TEST2%20%40%20wheezy._ipp._tcp.local/cups
  network dnssd://TEST3%20%40%20wheezy._ipp._tcp.local/cups
  network socket://192.168.7.64

The USB-connected printer and the networked one have definitely been discovered. They have device-uris

  usb://EPSON/Stylus%20COLOR%20740
  socket://192.168.7.64

A parallel port has also been found. Its device-uri is

  parallel:/dev/lp0

To identify the makes and models of any printers you will want to do

  lpinfo -l -v

In this case, an edited output is

  Device: uri = usb://EPSON/Stylus%20Photo%20RX420?serial=LJ4O40407152301540&interface=1
          class = direct
          info = EPSON Stylus Photo RX420
          make-and-model = EPSON Stylus Photo RX420
          device-id = MFG:EPSON;CMD:ESCPL2,BDC,D4;MDL:Stylus Photo RX420;CLS:PRINTER;DES:EPSON Stylus Photo RX420;
          location =
  Device: uri = parallel:/dev/lp0
          class = direct
          info = EPSON Stylus COLOR 740 LPT #1
          make-and-model = EPSON Stylus COLOR 740
          device-id = MFG:EPSON;CMD:ESCPL2,BDC,D4;MDL:Stylus COLOR 740;CLS:PRINTER;
          location =
  Device: uri = socket://192.168.7.64
          class = network
          info = HP LaserJet 2200
          make-and-model = HP LaserJet 2200
          device-id = G:Hewlett-Packard;CMD:PJL,MLC,PCL,PCLXL,POSTSCRIPT;MDL:HP LaserJet 2200;CLS:PRINTER;DES:Hewlett-Packard LaserJet 2200;MEM:8MB
          location =

The dnssd://... entries are print queues on a remote machine, not printers. DNS-SD has located them with the help of Avahi. Queues created with a dnssd://... device-uri should be set up as raw queues. A client machine with a cups version greater than or equal to 1.6.x will have the same queues found with avahi-daemon plus cups-browsed and listed with

   lpstat -t

You can either ignore the dnssd://... entries or not have them displayed by removing the dnssd backend from the list which

  dpkg-reconfigure cups

gives.

The device-uri for a Networked Printer

CUPS can use at least one of the AppSocket, Internet Printing (IPP) and Line Printer (LPD) protocols for connecting to printers and print servers over a network connection.

  • AppSocket

Also known as the JetDirect or RAW protocol, it is the most basic protocol that can be supported. The URI scheme is

socket://<ip_address_or_hostname>:<port_number>

The standard port number is 9100 and this will be used by default if it is omitted from the device_uri. Print servers with three outputs would require three port numbers; for example, 9100, 9101 and 9102.

It is questionable whether AppSocket is a protocol. There is no specified standard for it; no queue management; no aborting of jobs; no querying of printer supplies; no encryption. All it does is shovel the data for a print-ready file over the network and then close the connection. Because the only overhead is TCP/IP the data transfer is generally fast. Also, it has been in widespread use for a long time so the printer implementations of AppSocket are good.

  • IPP

Printing normally takes place over port 631 with the URI being

ipp://<ip_address_or_hostname>:<port_number>/<resource>

Unfortunately, the resource path has never been standardised and it may require some experimentation to determine what a printer or server will accept. Apparently, newer printers use /ipp/print in the path but for older products it could be something entirely different. Maybe the printer's front panel or

/usr/lib/cups/backend/snmp <ip_address>

will help. A CUPS server can be reached with

ipp://<ip_address_or_hostname>/printers/<print_queue_name>

In theory, the handshaking and status monitoring done by the IPP protocol should ensure reliable printing but, in practice, there are printers which do not implement some aspects of IPP very well.

  • LPD

This is the original network protocol with a URI of

lpd://<ip_address_or_hostname>/<print_queue_name>

The default port used is 515. CUPS has limited functionality for LPD-based clients but, even though AppSocket and IPP are seen as better alternatives, it is regarded as a reliable protocol.

Printer Drivers

The job of a printer driver is to ensure that printing options are applied by the scheduler and the filtering system and produce a final output which can be understood by the printer.

Drivers are in the printer-driver-* packages plus various other packages. The print server task in Debian Installer gives you a full complement of these drivers. You may decline this task at install time but after first boot you can do either

  apt-get install task-print-server

or

  apt-get install cups

If a driver/PPD for your printer is not in any of the installed packages you have various choices open to you:

  • Consult openprinting for ideas on available drivers.

  • Hunt down an appropriate package with

   apt-cache search search_term

Non-Free Printer Drivers and Firmware

Some driver software distributed with some printers does not meet the criterion of being DFSG-free, so users will have to rely on what the printer manufacturer has to offer to get their printer working. Also, even though their drivers are DFSG-free, some printers require proprietary firmware to allow full access to printer features and enhanced performance. The firmware is uploaded to the printer when it is powered-on attached to the computer.

It may also be necessary to go to the manufacturer's website if the printer is a new model and drivers for it are not yet in a Debian package.

  • Brother

Solutions for Linux is a good place to start for assessing what support your printer has from Brother. Generally, you will need .deb files for the cupswrapper and the lpr driver. Follow the instructions to install them; alternatively, there is linux-brprinter-installer to do that for you.

  • Canon

There is a wiki page ?dealing with Canon URF-II printers which should suffice for installing all Canon's package offerings.

  • Samsung

Linux support for a Samsung printer can be searched for from the Printers link at the Samsung Download Center. Many, but not all, Samsung printer models use the Unified Linux Driver (ULD). ULD contains PPDs for Linux supported printers, a printer driver to use with the PPDs and a library to use with the driver. It comes in a .tar.gz package and only supports the i386 and amd64 platforms. No source code is provided.

Extract the files in the tarball and install them by entering the directory created and running install-printer.sh

tar zvxf uld_v1.00.xx_xx.xx.tar.gz
cd uld
./install-printer.sh

Samsung does not provide ULD as a .deb but the The Samsung Unified Linux Driver Repository does. It also has a good deal of information on the installation of ULD and its interaction with a Debian system. SULDR is not affiliated with Samsung.

  • HP (firmware)

With hplip installed you can use the command hp-plugin (a download and install utility) to get the single plugin (firmware) file for your particular hplip release. Without hplip installed (maybe you just want a print queue with a printer-driver-hpcups PPD and have no need for hplip) the plugin installation is still doable with:

  1. Go to the Openprinting website and download the *.run file corresponding to the printer-driver-hpcups version.

  2. Make a directory and move your file into it.
  3. The file is a shell script containing needed plugins and other files. Make *.run executable with chmod 755 and look at its help with ./*.run -h.

  4. Check what you are going to install with ./*.run --tar vxf to extract the files from the script.

  5. Make installPlugin.py executable and do ./installPlugin.py.

  • foo2zjs (firmware and colour profiles)

Not the name of a printer manufacturer but a Debian package which can install firmware and colour profiles for a number of printers which use the ZjStream wire protocol. The commands (as root)

getweb | less
getweb p1008

give a list of what is available and download the firmware file for an HP LaserJet P1008. Hannah is a graphical firmware downloader which uses getweb. Re-plug the connection to the printer to upload the firmware to it.

The PPD file

PostScript Printer Description (PPD) files were originally used by printers which operated with PostScript as a Page Description Language (PDL) for printing. They have been adapted to cope with other standard printer languages such as HP's Printer Command Language (PCL) and special (often proprietary) languages. Driver packages include PPDs in their contents.

A searchable list of PPDs on your system is obtained with

  lpinfo -m | less

If there is only one for your printer the choice is made for you! If there is more than one, go for the PPD which is marked "Recommended". If none are recommended use common sense (sometimes called "guessing" :) ) or seek help from the openprinting database.

Some Generic PPDs are listed with lpinfo -m and one may be a solution when every driver package is installed and your printer model is not in the list. You can also resort to the printer manufacturer's website or a CD which came with the printer.

It is convenient (and probably sensible) to put a PPD obtained from elsewhere in /usr/share/ppd/custom. It will then be displayed in the output of lpinfo -m and by the web interface.

Creating a Print Queue with lpadmin

This is the basic method to set up a queue. It is used behind the scenes with programs like system-config-printer and the web interface. There are four essentials to provide when setting up a working, accepting print queue with lpadmin.

  1. The queue name (-p): The printing system treats the name in a case-insensitive manner; LaserJet-300 is the same queue as laserjet-300.

  2. The device-uri (-v): The destination for a print job; usually a printer.
  3. The PPD file (-m or -P): Determines how the print job is handled by the filtering system to produce data which can be successfully printed by the printer.
  4. Whether the queue is enabled (-E}: Must be specified explicitly.

With this information:

  lpadmin -p queue_name -v device_uri -m PPD_file -E

sets up the queue.

Sometimes it is necessary or desirable to establish a raw queue. That is, a queue where the filtering system is not involved and the print job goes directly to a printer or another queue.

  lpadmin -p queue_name -v device_uri -m raw

lpoptions is the command to use to see default printer-specific options (obtained from the PPD) for the queue.

  lpoptions -p queue_name -l

Options which are not specific to the particular printer come from

  lpoptions -p queue_name

The previous lpadmin command is about as simple as it gets for setting up a queue quickly but it can be tweaked just as simply by giving the command some printer-specific and non-specific options to add with -o.

The lpadmin and lp manuals are sources for non-PPD options.

Setting up a queue requires either root privileges or for the user to be a member of the lpadmin group. If you installed CUPS using the print server task in the Debian installer the first user is put in the lpadmin group.

Check for user membership of the lpadmin group with the command

  groups

Creating a Print Queue with the CUPS Web Interface

http://localhost:631 is the location of the interface and from there you can administer print queues, including their installation. Administration tasks are able to be completed by giving the root name and password or the user name and password of an lpadmin group member.

The Add Printer button could produce a first page with something like this on it:

             Local Printers:    Serial Port #1
                                Serial Port #2
                                EPSON Stylus Photo RX420 (EPSON Stylus Photo RX420)
                                EPSON Stylus COLOR 740 LPT #1 (EPSON Stylus COLOR 740)
Discovered Network Printers:    TEST1 @ wheezy (HP HP DesignJet 750C)
                                TEST2 @ wheezy (HP HP DesignJet 750C)
                                TEST3 @ wheezy
                                HP LaserJet 2200 (HP LaserJet 2200)
     Other Network Printers:    AppSocket/HP JetDirect
                                Internet Printing Protocol (ipps)
                                Internet Printing Protocol (ipp14)
                                Internet Printing Protocol (https)
                                Internet Printing Protocol (http)
                                LPD/LPR Host or Printer
                                Internet Printing Protocol (ipp)

Which doesn't look significantly different from what lpinfo -l -v gave previously.

Under Local Printers: are the discovered printers which are directly connected to the machine being used. Discovered Network Printers: are networked printers on the same subnet as your machine. Or they could be print queues which the dnssd backend has found on the same subnet. In both cases backends have been run in discovery mode to find printers. The device-uri found is on the second page.

Other Network Printers: gives you the opportunity to provide the device uri and ppd for a printer or queue which falls into neither of the previous two categories. The information is provided on the second and third pages.

Having made a selection from Local Printers: or Discovered Network Printers: you should find a queue name based on the printer make and model has been filled in for you on the next page. Change it by all means if you wish. Once it is done it cannot be modified later because a new name would imply setting up a different, new queue.

Share printers connected to this system on the Administration page is the basic facility to allow (or not allow) DNS-SD broadcasting on Debian 8.x.x. Ticking Share This Printer on the second page designates your queue as one to add to this facility.

Moving on to the third page you should find that a PPD has been selected for you, unless

  • The printer provides no make and model information to CUPS.
  • There is no PPD for the printer on the system.
  • Other Network Printers: is being used.

The previous driver and ppd comments apply here too.

The final page has the printer-specific options from the PPD and a few non-specific printer options. This should suit the needs of many users.

Double Filtering

The CUPS web interface and the command /usr/sbin/lpinfo -v give a list of printers and print queues discovered on the network. Any of the entries in the list can be installed as a local print queue. In other words they will listed in /etc/cups/printers.conf on your machine.

For example, under Discovered Network Printers in the web interface you might see

  testq@desktop (DCP-9020CDW)

and the next web page shows a Connection beginning dnssd://.

The dnssd:// tells you this is a print queue discoverd by avahi-daemon. The (DCP-9020CDW) tells you the make and model of the printer. This latter information is obtained from the *Product line in the queue's PPD, so it implies the queue is not a raw queue and a job sent to it undergoes filtering. The same information is given in the make-and-model field of the output of /usr/sbin/lpinfo -l -v.

On the third web page you should choose Raw as the Make. With lpadmin you should have no -m option or -m raw. Then the client passes the data through without filtering and all filtering is done correctly on the server.

Alternatively, you can get such queues automatically set up locally by running cups-browsed on the client.

Upstream CUPS has something to say about double filtering. Quoting:

The issue is the MIME typing on the CUPS server - if the server
doesn't recognize the MIME media type then you may end up with
extra filtering.

I'm not saying it can't work (because we have customers that use
that configuration all of the time), it is just that we get a lot
of support calls when people try to do Microsoft-style printer
sharing to a server that is also hosting a CUPS printer driver on
the same queue.

Reinforcing the previous point:

The issue is that for IPP we actually get to use MIME media types,
and the filters in the PPD file specify what the final output type
is. We then try to match things up on the remote system, which is
where the problems typically occur. For example, if the local
driver has a filter that specifies application/vnd.hp-pcl" as the
destination MIME media type but the server does not have that MIME
media type defined/supported for its queue, we have to revert to
"application/octet-stream" (auto-detect).

You can "fix" this with .types and .convs files on the server 
to specify a "-" filter for the affected MIME media types to
application/vnd.cups-raw) but ultimately you are better off
letting the server do the filtering...

You are strongly advised not to do double filtering. Set up the queue on the client as a raw queue if the remote queue is doing the filtering.

cups-browsed

This package was introduced for CUPS 1.6.x and is necessary on a Debian 8.x client machine if you want to discover print queues broadcast with DNS-SD (Bonjour broadcasting) and have them available in the print dialogues of GUI applications and usable by command line programs. Documention is in /usr/share/doc/cups/README.Debian.gz, /etc/cups/cups-browsed.conf, cups-browsed and cups-browsed.conf. The avahi-daemon package also needs to be installed on the client. The default cups-browsed.conf is set to do both DND-SD (Bonjour) and CUPS discovery of print queues.

A server with a CUPS version of 1.6.x or greater does not need cups-browsed to do DNS-SD broadcasting but avahi-daemon is required.

DNS-SD Broadcasting (Server)

DNS-SD Discovery (Client)

Debian Version

Wheezy

Jessie

Wheezy

Jessie

cups-browsed needed

Not available

{X}

Not available
Use dnssd backend

(./)

avahi-daemon needed

(./)

(./)

(./)

(./)

CUPS Broadcasting (Server)

CUPS Discovery (Client)

Debian Version

Wheezy

Jessie

Wheezy

Jessie

cups-browsed needed

{X}
Not available

(./)

{X}
Not available

(./)

avahi-daemon needed

{X}

{X}

{X}

{X}

Printing and GTK Applications

The section on cups-browsed might give the impression that no printing can take place from a Debian 8.x.x client without it. This is not quite the case; it all depends on what you are printing from. Nevertheless it is worth repeating that cups-browsed promotes printing from all applications and from the command line.

Iceweasel, Evince and gedit (to name three) use the GTK print dialog as a printing subsystem. The subsystem gets print queue information directly from Avahi and the queues appear in the print dialogues of applications. cups-browsed isn't needed and neither for that matter is CUPS.

The print dialogues of Qt applications (Okular, Konqueror etc) and LibreOffice do not have this feature as yet.

Printing Without a Local CUPS Server

Print queue availability using browsing is a dynamic process. Queues will come and go as they are enabled and disabled or as a machine is moved from network to network. In a world which more and more has a focus on mobile devices there are benefits to be gained from avahi-daemon and cups-browsed or from a print dialogue which implements Avahi discovery itself.

However, it is possible a static configuration is entirely suitable for some purposes. In other words, no avahi-daemon, no cups-browsed and no cupsd running on a machine and instead connecting to a designated server. The first step is to read this manual. Then

  apt-get install cups-client

followed by making the directory ~/.cups and putting a file client.conf in it.

  mkdir ~/.cups
  touch ~/.cups/client.conf

The content of client.conf could be as simple as

  ServerName 192.168.7.20

The local queue is eliminated and print jobs from all applications and the command line go straight to ServerName for processing. There is the bother of changing ServerName when moving from network to network but this may be balanced by not having to run three daemons,

Even a client.conf may be dispensed with if the only printing to take place is from the command line. At its simplest:

  lp -h server_IP_or_hostname -d print_queue_on_server print_job

Configuration Files for the Scheduler, cupsd

These are located in /etc/cups as cupsd.conf and cups-files.conf. The existence of two files arises from a Debian bug report which lead to the fixing of a privilege escalation from lpadmin to root on systems with all options contained in cupsd.conf. as they were at that time.

cups-files is editable only by root. cupsd.conf can be edited by root and, from the web interface only, by a user who is a member of the lpadmin group. After editing either file cupsd has to be restarted:

  service cups restart

It can be very convenient to change some of the cupsd.conf settings with cupsctl (as root only). The current settings displayed by

  cupsctl

might be

  _debug_logging=0
  _remote_admin=0
  _remote_any=0
  _share_printers=0
  _user_cancel_any=0
  BrowseLocalProtocols=dnssd
  DefaultAuthType=Basic
  JobPrivateAccess=default
  JobPrivateValues=default
  MaxLogSize=0
  SubscriptionPrivateAccess=default
  SubscriptionPrivateValues=default
  WebInterface=Yes

Change a displayed setting with

  cupsctl Webinterface=no

and, for a setting which is not displayed:

  cupsctl SystemdIdleExit=Off

More than one line in cupsd.conf can be changed with some commands and cupsd is restarted when cupsctl is used. cups-files cannot be altered with cupsctl.

See also