Up one level
Printing in Linux using CUPS
Spencer Stirling

...at least for the HP Deskjet 3650 (USB connected printer)
Setting up a printer in Linux is, loyal to Linuxdom, unnecessarily annoying. Frankly, the documentation "to just get things working" is seriously lacking (in my mind, at least). First, you will need to realize that most/all applications in Linux print in Postscript format. How the application actually talks to the printing system is through a high-level printing system (e.g. CUPS, which we will discuss below). It is the job of CUPS to provide a standard interface for applications to talk to. CUPS takes the Postscript print files and, if necessary, passes them to a set of low-level drivers (printer dependent) which then converts the data into a language that the printer can understand and sends it to the printer itself. There are several examples of these low-level drivers: HP printers have a driver called "hpijs", Ghostscript is a program which converts Postscript files into a format that many printers can understand, and finally there are many so-called GimpPrint low-level drivers which are based on the Gimp project.

If your printer supports Postscript format directly then it is unnecessary to install a low-level driver - you can just print the raw files out to the printer in "raw" mode.

Topmost level: CUPS
At the topmost level is the common interface that Linux provides to applications. Over the years there have been several of these: BSD style (lpr commands), SYSV style (print, cancel, etc.), XPrint, and a couple of others. Now the best interface is CUPS (Common Unix Printing System).

Start by installing the cupsd server daemon which is found in the Debian package "cupsys". You will also need to install the Debian package "cupsys-client". As an added convenience, CUPS is actually able to emulate the BSD style (lpr command) interface - just install the Debian package "cupsys-bsd".

It is important (at least to me) that you only have a SINGLE toplevel printing system installed. One big annoyance for me was that, in Debian, the XPrint system comes along with the basic XWindows installation. This was causing a lot of conflicts with CUPS, and I also had strange printers showing up in Mozilla Firefox. Then I figured out that the Debian packages "xprt*" were installed - removing them cleared up the issues.

Bottom level: Printer driver
CUPS doesn't actually talk to the printer, however. It is just an interface for all of your fancy applications. To do the actual talking, you will need a low-level printer driver (unless the printer supports Postscript natively, or if the printer will only be a Samba printer: see below).

The best place to figure out which driver you need is by visiting the Master site www.linuxprinting.org. I recommend reading the documentation there before embarking on this mission. In order to figure out the driver that I needed, I just searched the database for my printer (an HP Deskjet 3650). The recommended driver was "hpijs", although for *added* functionality the "hplip" driver was *also* suggested - both are drivers provided by HP. Note that many drivers will actually be Ghostscript-based drivers (i.e. it will use "gs" to actually talk to the printer - in this case you will need to compile your specific driver into Ghostscript, OR you can install the Debian package "gs-esp" which contains many drivers already compiled IN!!!). Still further drivers will be based on the Gimp (see below)!!! Often times several drivers will actually work - first try the recommended driver. Remember that if your printer supports Postscript natively then there is NO NEED FOR A DRIVER!!!

In my case, however, I don't need to worry about Ghostscript or the Gimp since I am using "hplip" AND "hpijs" (both at the same time - I haven't been able to get hplip to work without hpijs installed underneath. Also I actually think that "hplip" and "hpijs" secretly rely on Ghostscript, but that's not my problem). So I just installed the Debian packages "hplip" and "hpijs".

A little explanation is in order about "hplip" and "hpijs" (versus the almost-defunct "hpoj"). The "barebones" driver is just "hpijs" - this is good just for simple printing (but nothing more - i.e. no bidirectional support such as scanning, faxing, etc). If you use that then in CUPS (see below) you can simply use the bare USB/parallel port where the printer actually sits. The "hplip" driver does something more - it takes over the bare USB/parallel port and creates another virtual "hp" port. This provides bidirectional functionality, as well as support for printers that might be on the network. So "hplip" is a nice addition if you can use it. There is a different add-on driver called "hpoj", but my understanding is that this is no longer being developed in favor of "hplip" - however you might need to use it, especially if you don't use the CUPS interface (see above).

Update: I had the displeasure of installing an HP 1000C on a parallel port. In this case I used instead the driver "pnm2ppa" - also available as a Debian package. I'm very confused because linuxprinting.org recommends "pnm2ppa", but then below it recommends either "hpijs" or "hplip". I don't know if "pnm2ppa" somehow depends on the HP drivers (because those just happen to be installed for a different printer anyway), but I DO know that this printer WON'T work without the "pnm2ppa" driver. *SHRUG*

Gluing top and bottom together: Foomatic
Now you will need to make it possible for CUPS to talk to your printer driver. This is where the Foomatic project comes in. So first install the package "foomatic-filters".

Now it is time to download the ACTUAL configuration for YOUR ACTUAL PRINTER. This comes in what is called a PPD file. If you are lazy (and you have a lot of disk space) then you might find your printer's PPD (and many others) if you install the Debian package "foomatic-filters-ppds". In my case, however, I'm disk-space cheap so I manually downloaded the PPD for my HP Deskjet 3650 from www.linuxprinting.org (you were there before when you were trying to find out the appropriate printer driver for your printer. When you searched the database for your printer it gave the printer driver and next to it the appropriate PPD). Download the PPD file and place it in the /usr/share/cups/model directory. Be sure to make it readable by everyone by using "chmod a+r HP-Deskjet_960C_hpijs.ppd".

There does seem to be another way to do all of this stuff if you don't like going to "linuxprinting.org", but it seems (to me) to be more trouble than it's worth - I'm probably wrong (or I probably misunderstand what these programs actually DO). I'm putting it here for future reference. There are packages called "foomatic-db" and "foomatic-db-engine" which (I think) enable you to browse the huge linuxprinting.org database in some automated fashion - I have no idea how this works, and I don't really care at this point. I'm getting along perfectly well without it. There are add-ons called "foomatic-db-hpijs" and "foomatic-db-gutenprint" (formerly known as "foomatic-db-gimp-print"), but everything seems to be working, so that's that.

Again, if you have a native Postscript printer then none of this is actually necessary. On the other hand there is a postscript.ppd available from linuxprinting.org which might allow you to take advantage of special Postscript features for your printer (for example it allows you to downgrade the Postscript version if your printer is a little old - it is very likely that applications will print in Postscript 3 but your printer only understands Postscript 2).

Now you must restart the cupsd daemon to read in the new ppd - in Debian I type "/etc/init.d/cupsys restart".

Configuring CUPS
Now finally it is time to configure CUPS (actually add your printer to the CUPS system). KDE has some built-in tools for this. I personally prefer adding the printer through a web browser by going to the URL "" - apparently cupsd listens on port 631 and all administration tasks are handled through cupsd. This interface is rather self-explanatory. Try printing a test page and see if it works!!!

Remember that if your printer is a Postscript printer then you don't have to select a printer driver: JUST USE RAW mode!!! (unless you specifically installed the special postscript.ppd file from linuxprinting.org).

Samba HELL
If you want to share your printer to Windows machines then you will need to dive into Samba hell. Most modern versions of samba integrate with the CUPS libraries - I will only talk about these modern versions.

As far as I can tell, there are two convenient ways to share your printers to Samba clients using CUPS. The first (easier and better) involves only a few steps. The second is really a variation on a theme, and is only useful to appease stubborn Windows users.

You will first need to set up the Linux computer that is the print SERVER (i.e. get the printer working there first before you try to share it out). After the printer is working on the server you will need to share it in Samba. So in /etc/samba/smb.conf put in the lines

load printers = yes
printing = cups
printcap name = cups

under the [global] section, and also put in the lines

comment = All Printers
browseable = no
printable = yes
public = yes
guest ok = yes
writeable = no

later in the file. Restart the samba daemons and off you go!

On the client (probably Windows) machine just install the printer to send data to the network using a driver that puts out Postscript format (I think the Apple Laserwriters do, for example). If your client is a Linux box (and you still want to use SAMBA) then install a CUPS printer on the CLIENT, except specify the output port as a Windows/SAMBA printer (you won't need any low-level drivers, and you won't need foomatic - the drivers on the SERVER will take care of that). You will then need to specify the URL where the printer can be found on the network, i.e. smb://printservercomputer/hppsc1510. Choose "raw" as the output format.

The second way to share with SAMBA is a bit more cumbersome. Unfortunately most Windows users like to install special drivers for each printer. Even if you try to install a Postscript printer they always complain that somehow they "paid" for that special HP driver and they want to use it!!! Silly. In that case you will need to do all of the above EXCEPT for 3 things:

Instead of installing your printer as usual on the Linux SERVER, you will need to use the "raw" format (i.e. don't use any low-level driver). This is because the Windows CLIENTS already have a driver which outputs information in a language that the printer can understand. Since you will probably want to use your printer from both the Linux server and the Windows clients this will require you to install two printers in CUPS: one "raw" printer for the Windows idiots and one conventional Linux printer with a low-level driver for use on the server.

The second change is that you also add the line

use client driver = yes

to the [printers] section in smb.conf as outlined above. Finally, you need to tell the CUPS daemon cupsd to allow for raw mode (I think this is a security setting). So in the files /etc/cups/mime.types and /etc/cups/mime.convs you will find lines with the phrase "#application/octet-..." - you need to uncomment these lines from BOTH files!!! Don't forget to restart the cupsd daemon!!!

It is clear that the first way is more secure, much much easier, and just better in every way. I would only use the second if I had to drop in a Linux box for an old Windows server where 50 machines on the network already had printer drivers installed (and I didn't want to bother changing them!!!).

Printing from within the Gimp 2.2.6
Printing from within the Gimp is very easy, as long as you have the "gimp-print" package installed along with the base "gimp" package.

Furthermore the Gimp printing system can actually be used as a set of low-level drivers for the whole system (not just from within Gimp). Apparently these drivers produce much better results for photo-quality printing than, for example, "hpijs". In Debian you can install these drivers by installing the packages "cupsys-driver-gimpprint" (now called "cupsys-driver-gutenprint") and "cupsys-driver-gimpprint-data".

That being said, I haven't found it necessary so far. However, there is a problem (which I think shows up whether you use the gimp printer drivers or not). Let's suppose that you have a CUPS printer named "hpdeskjet960c" installed - this is a regular printer that accepts Postscript files as usual in Linux. When you try to print an image from the Gimp, this printer will show up (since it is the default) and it will be of type "Postscript 2". However, if you try to print it then it will not work. Update: this has been fixed in Gimp 2.2.9 (and maybe earlier). Still see below for useful commentary. At least for me, nothing happened - the job didn't even show up in the queue. Pressing "Setup Printer" from within Gimp I see that the print command is:

lp -s -dhpdeskjet960c -oraw

It is the -oraw option that is the problem. This option tells CUPS to not use the low-level printer driver but instead send it through in RAW mode. However Gimp thinks that this is a printer of type "Postscript 2", hence Gimp will print a Postscript file which CUPS will in turn attempt to send DIRECTLY TO THE PRINTER. Obviously this won't work.

There are two possible solutions (but NOT BOTH at same time!!!):

1) Remove the -oraw option. This will use the low-level driver that is being used by CUPS (e.g. hpijs).

2) Keep the -oraw option BUT in the "Printer Model" selection (on the same Gimp printer setup screen) you must select the appropriate model for your printer. This will use the gimp-print low-level drivers.

These settings can be saved for future use at the bottom of the Gimp Print dialog.

This page has been visited   times since May 30, 2005