Sharing a printer to Windows XP clients with Samba and Cups
Posted by Anonymous on Mon 31 Jul 2006 at 11:07
Setting a printer in Debian Sarge from scratch and make it available for Windows XP clients on a LAN can be difficult, but using CUPS and samba it should be fairly straightforward if you have a supported printer. Here we will demonstrate how to do this.
Printing for the first time in a machine with a fresh install of Debian Sarge is not as easy as one might think. I came across many documents and web pages in the Internet that explain in a general way what I was trying to do, but none of them alone solved my problems and sometimes I didn't find what I was looking for in any of them. So, I wrote this guide to remember the solution to my problem and to share it with other people. This guide details all the problems I went trough -and the solutions – to make my printer available in my home's LAN. The LAN is formed by five PCs: Three desktops and two laptops. The machine running Debian Sarge is my own computer and the others, including laptops, run Windows XP. The printer is an old Epson Stylus Color 777.
Part 1: The Nightmare
First we must make sure we can print from the Debian Sarge PC to the printer attached to it. We must install and configure CUPS -the Common Unix Printing System- and for that we need to install the next packages that -as weird as it sounds- are not installed by default in a fresh desktop install of Sarge:
- cupsys
- cupsys-client
- cupsys-driver-gimprint
- cupsys-driver-gimprint-data
Besides these packages, Synaptic selected the next packages or they were already installed:
- libcupsimage2
- libcupsys2-gnutls10
Finally, this package is necessary or Mozilla Thunderbird won't print at all:
- cupsys-bsd
The packages can be installed usingSynaptic or using the apt-get command as usual for Debian.
Once CUPS is installed we can add the printer. This can be done from a web browser opening the address http://localhost:631/ or from the KDE Control Center. The first problem hits us when we try to add the printer using the Control Center and in the part where we are supposed to choose the printer port we don't find lp0, the parallel port, but unknown-parallel0 We choose that option anyway and of course it doesn't work, the printer doesn't print a single character.
After a lot of time searching in Google and discovering a lot of people with the same problem but different solutions, we try some of them and discover that what is missing is the lp module in the kernel. So, we edit the file /etc/modules and add
After rebooting (ok, I know you don't need to reboot to load a module, humor me) the port lp0 appears in the KDE Control Center. We use it again to add the printer in lp0 and choose the right driver. In this case the driver:
Epson Stylus Color 777 -CUPS+Gimp-Print v4.2.7
In the bottom part of the Control Center we can see the option "Print System Currently Used" and we change it to "CUPS". The printer must NOT be configured as RAW and we can leave "USER ACCESS SETTINGS" blank. Finally as the printer name we type StylusColor777. That should be all and really excited we open any program, try to print and...nothing, zero, no error messages, no badly printed pages, nothing. The programs seem to print well but the printer doesn't move at all. This is really discouraging because there are no error messages and we have not a single clue of what is happening. We loose an entire day searching solutions in the Internet. There are several people with the same problem but not a working solution, nobody knows how to fix this.
Keep in mind that this is a fresh install of Sarge. Amazing! Finally, fooling around the directories and files we open the file /var/log/cups/error_log and discover the following lines appear each time we try to print:
E [22/Oct/2005:13:29:58 -0500] Unable to convert file 0 to printable format for job 6! I [22/Oct/2005:13:29:58 -0500] Hint: Do you have ESP Ghostscript installed?
We do a Google search for ESP Ghostscript and discover it refers to the package gs-esp (the Ghostscript PostScript interpreter - ESP version) that OF COURSE is not installed. We proceed to install it using:
apt-get install gs-esp
What is this program supposed to do? Here is part of the package description which explains:
Ghostscript is used for PostScript preview and printing. Usually as a back-end to a program such as ghostview, it can display postscript documents in an X11 environment. Furthermore, it can render PostScript files as graphics to be printed on non-PostScript printers. Supported printers include common dot-matrix, inkjet and laser models.
We try to print a page... works perfectly! Two days lost but it is worth it! To this point we see that all the errors seem to be the distribution's fault. gs-esp should have been installed along with CUPS and lp not installed by default seems to be a hardware detection problem. From now on, we can print locally from the Debian Sarge PC.
Note: The Gimp needs to be configured independently from CUPS to print or it will only print random characters. In this case you only have to start the program, go to the 'Print' menu and choose the right driver and type of paper.
Part 2: Make the printer available using SAMBA
This task was another nightmare. The goal was to make the printer available to the Windows XP clients using SAMBA in anonymous form, this means the Windows XP clients don't need to use a login or password. (This is because my parents and brothers are the users and they don't seem to be able to memorize a password.)
Making the printer available requires three thing: CUPS configuration, SAMBA reconfiguration, and the configuration of each client with Windows XP installing the right drivers.
CUPS Configuration
After a lot of searching on the Internet and trying several times to access the printer from the windows clients - the printer doesn't appear at all in the LAN we discover that we must modify the file /etc/cups/cupsd.conf and add the line:
Allow From 192.168.1.*
This IP address may change with a different router. This will tell CUPS to accept printing from any machine connected to the local network.
Next, we must configure CUPS to allow printing in a RAW format from the Windows clients. For that we must modify two files: The first one is the file /etc/cups/mime.convs where we must uncomment the following line :
application/octet-stream application/vnd.cups-raw 0 -
The second change we must make is in the file /etc/cups/mime.types where we must uncomment the following line:
application/octet-stream
SAMBA Configuration
The next step is to configure SAMBA by modifying the file /etc/samba/smb.conf.
The file smb.conf in my computer is the next one:
[global] workgroup = KAMEHOUSE netbios name = HARPIA security = share #this section is only to share the printer printcap name = cups disable spoolss = Yes show add printer wizard = No printing = cups [printers] comment = Printer in Linux path = /var/spool/samba guest ok = Yes printable = Yes use client driver = Yes browseable = No
This example of smb.conf works perfectly and we will comment on it in a moment. The notable fact is that if we try to print from any Windows XP machine we won't get anything at all, only another error. We locate the problem when we check the file /var/log/samba/log.smbd:
'/var/spool/samba' does not exist or is not a directory, when connecting to [StylusColor777]
That's true. Even when SAMBA's official documentation and all examples that we find around show "path=/var/spool/samba" as the spool directory, this directory is not created in Sarge when SAMBA is installed!!! So we create it with:
# mkdir /var/spool/samba
Aditionally we must give to it the necessary rights so that the Windows clients can write to it:
# chmod 777 /var/spool/samba
This must be done because when a printer job arrives to a SAMBA server, the information is written temporarily in the directory specified by the option 'path' in the 'printers' section of smb.conf. SAMBA then executes a command to send this information to the printer.
Now some comments about the file smb.conf. The important sections for printers are [global] and [printers]
workgroup = KAMEHOUSE
The workgroup must be the same workgroup of the Windows XP machines.
netbios name = HARPIA
Here we set the netbios name of the Linux server in the Windows XP network
It is important that we specify cups with:
printcap name = cups
This is the way in which SAMBA tells Windows the name of the printer available in CUPS. If we don't use 'cups' we will see in the file /var/log/samba/log.smbd the error message:
Unable to get jobs for ipp://localhost/printers/lp client-error-not-found
Windows Client Configuration
The steps to configure the machines with Windows XP are demonstrated in the following screenshots.
If everything has been configured properly and the printer works then it will appear automatically. The drivers to use are the Windows XP native drivers or the ones in the printer install CD. The process must be repeated en each of the Windows XP machines. At the end you should be able to print from any of these machines. Even from the wireless connected laptops.

You must choose the network printer not a locally attached one.

If everything has been properly configured in Debian Sarge the printer must be available when you choose 'Browse for a printer'.

Note that the printer appears with its CUPS name, in this case StylusColor777

You can choose to make it the default printer or not:


Here we must choose the driver for the model of the printer. If Windows XP doesn't have the driver we must use the printer installation CD. If there are no drivers available for the printer you can select the drivers for a postscript printer. For example Apple Laserwriter o the Postscript driver from Adobe (available on their web site), if it is a color printer you can choose Apple Color Laserwriter. The drivers may print with a little less resolution but they work. This is because everything is send as postscript to CUPS and CUPS understands postscript just fine. This has a big advantage,if you have an old printer that doesn't have drivers for Windows anymore, you can use it just fine in the network if it works in Linux.


This is the last step and the Windows machine will be able to print to the Linux server.

This is pretty useful, isn't it? It took me a couple of days but I learned a lot about CUPS and SAMBA, specially looking at the log files. Next time I'll bring another piece to the puzzle, how to print to a printer connected to one of the Windows XP machines from the Debian Sarge PC.
by Cesar Chaparro
XP can do printing direct to cups.
This what is called ipp internet printing protocol. just use
ipp://yourdebianhost:631/printers/Yourprintersnamehere
voila you can use it.
Aehm and you can also use a anonymous account for cups under XP.
You also dont need any postscript-adobe driver.
just give the /etc/cups/???/yourprinter.ppd to your client.
[ Parent | Reply to this comment ]
I didn't say that you needed to use postscript drivers. I said you should use the native printer drivers BUT if you didn't have them (old printer maybe) then you COULD use postcript drivers.
Glad to see there are several ways to solve the same problem :)
Cesar
[ Parent | Reply to this comment ]
But really what kinda lame things did you stuck? doesn't existing directories, missing kernel modules, this so basic, the half of the article is crap and in my opinion you should check the printer's compatibility before you buy that.
Yes this is right you don't need samba, end if you lamer don't write articles like this about samba cups setup. IPP is more simple, samba not a game for newbies like you...
Printer support compare to the windows is lacking, and maybe it's complicated but if you would read the specific howtos then it wouldn't be so hard but if someone crying because debian doesn't contain things by default i suggest that go back to fedora...
So we don't appriciate your help, even if it was your intention, it's another meaningless article and another kilobytes wasting on the web, Good Job!
[ Parent | Reply to this comment ]
I consider myself a fairly experienced Debian user; I have been using it from the very day Potato was released. And yet, a year ago it took me 2 days of googling around and reading many contradictory howtos to get network printing in a mixed environment working.
It seems like ESR, who - I hope - wont be labelled a 'lamer' by you, had a similar experience:
http://catb.org/~esr/writings/cups-horror.html
Go read his article and think about it. The truth is that CUPS is an experience in frustration, and on top of that its Debian packages leave a lot to be desired.
On a more positive side, last time I've tried configuring printing from Ubuntu, it just worked, so maybe this whole mess *can* be rectified afterall :)
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
you're = you are
It's bad form to make a glaring grammatical error while making fun of someone's spelling.
For the record.
[ Parent | Reply to this comment ]
love,
Isaac
[ Parent | Reply to this comment ]
Set up a network printer with http://yourdebianhost:631/printers/Yourprintersnamehere (not ipp://, at least that didn't work for me)
I think if your printer includes a postscript driver you can use that, but if not then you will need to user either the adobe postscript driver http://www.adobe.com/support/downloads/product.jsp?product=44& ;platform=Windows or the CUPS postscript printer driver (I couldn't actually find a Windows binary, but the CUPS documentation claims there is one). The postscript driver will ask for your ppd file, which you can get from /etc/cups/???/yourprinter.ppd
If you run winbind on your CUPS server then you can use the hostname for the network printer address, if not you can use the IP address directly.
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
I used to get printing up and running on my Debian systems with the apsfilter package. It was/is simple to configure and required extra packages only in a few special cases. I needed to add hpijs for two of my printers and, for example, html2ps would have to be added if you wanted to print web pages. Programs were happy with apsfilter as the configured filter was written to /etc/printcap and sharing printers through Samba was no problem.
A few years ago, I decided to switch to CUPS as it seemed to be the way everyone was going (except for the Debian Project, still ;) ). I installed the six or seven packages I needed and then proceeded to read documentation and try various configurations for the next several days to get shared printers usable. I guess it was just me and ESR that found the information on linuxprinting.org/cups.org very confusing back then: go here, go there but first check this link or you may have to use these other links before you download this and that and go here and there and configure those and them. In the end, the best help I found was on random linux-help pages. It was around this time too that I realized that half the CUPS/Foomatic programs I downloaded I didn't need.
To think that all I needed to type to get my laptop to used a samba shared printer through my desktop was:
smb://user_name:password@work_group/host_name/printer_name
What could be more intuitive than that? And, back then, you had to intuit it because it was nowhere to be found in the documentation.
A pre-installed printing solution agreed upon by most in the GNU/Linux community would be a good thing.
[ Parent | Reply to this comment ]
Same thing here. I started reading the official CUPS and SAMBA documentation and ended visiting a gazillion different web pages in english, spanish and french. I also realized that I didn't need some of the packages I had installed. I hate to admit it, but once CUPS and SAMBA are installed things from the Windows side are a no brainer.
Cesar
[ Parent | Reply to this comment ]
With the solution you choose the windows client is the RIP and therefore requires the right driver on the (Windows) client (Spooling RAW Files to CUPS). IMHO the better way (for lots of clients) would be to make CUPS the RIP and acting as a generic postscript-printer towards Windows (by using PPDs and CUPS Filter Queues). And i qoute:
"This feature enables CUPS to do a few tricks no other spooler can do:
* act as a networked PostScript RIP (Raster Image Processor), handling printfiles from all client platforms
in a uniform way;
* act as a central accounting and billing server, as all files are passed through the pstops Filter and are
therefor logged in the CUPS page_log. - NOTE: this can not happen with "raw" print jobs, which always
remain unfiltered per definition;
* <b>enable clients to consolidate on a single PostScript driver, even for many different target printers.</b>"
To cut it short please see/read Point 1. 3. and 5. of:
http://www.linuxprinting.org/kpfeifle/LinuxKongress2002/Tutorial/ IX.CUPS-Samba/IX.Samba-HOWTO-Collection-Chapter-7.html
The whole document can be found under:
http://www.linuxprinting.org//kpfeifle/LinuxKongress2002/Tutorial
No offense - but I spent months myself getting this right for 200+ clients.
[ Parent | Reply to this comment ]
Thanks. Far too many web pages that claim to "explain" something skip over the mistakes that were made, and as a result, the reader learns much less than they could have! By exposing your mistakes (or perhaps the questionable choices made by your distribution and the ports you installed) you allowed us all to learn much more.
Life is different from the man pages. :)
eastpole
[ Parent | Reply to this comment ]
Thanks for writing this article. I used a lot of time figuring out how to get XP to print on my Debian. However, I have a problem I need some help on: The docs I print out is never removed from the printing queue (viewing from the local XP).
I AM able select the doc that was printed out and delete it manually in the queue, but that really should be unneccessary.. :)
Any hints?
thomahawk
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
The fact that you write with a little personality is helpful too.
[ Parent | Reply to this comment ]
This article is very good and helpfull.
[ Parent | Reply to this comment ]
This article is very good and helpfull.
[ Parent | Reply to this comment ]
Short and simple, if only I have found it earlier would have saved days of "read read type type type read type oops doesn't work"
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
Good article.
I have an HP CLJ 2700 connected to my Etch computer, that I wanted to share with Windows computers at home.
I was hoping that by now, it would work a little more out of the box than a few years ago. I first made a few tests with small changes in the original smb.conf that comes with SAMBA, without success.
I then just copied the smb.conf file from this article and changed it with my local names. Then I could immediately see the printer from Windows, but when I tried to install it with the Windows drivers from the printer's CD, the Windows wizard hanged while trying to connect to the printer.
Since I was trying to use an out of the box-configuration as much as possible, I didn't edit the file /etc/cups/mime.convs, which might explain the problem I was having (the CUPS-printer I was trying to set up on Windows was installed with an HPLIP-driver in CUPS).
Finally, my working solution is the following:
- Two printers created under CUPS for the same physical printer connected to USB: one with the HPLIP driver for local printing, one with RAW-configuration for printing from Windows.
- The smb.conf from the article (I used "kill -HUP `pidof smbd`" to reload smb.conf for testing changes)
- Installation in Windows (XP and 2000) as explained in the article, with the Windows drivers from the HP-CD.
Nothing more, the rest is all standard aptitude-installation (I had installed CUPS earlier, and installed SAMBA for the occasion from the "samba"-virtual package).
Works perfectly on both Linux and Windows.
Cheers,
Alain
[ Parent | Reply to this comment ]
All in all this article helped me take a printer that had no NIC (only parralel) and turn it into a network printer that users can add to their windows XP machines at the double click of a mouse! No additional Windows license neccesary! Just a Dell GX1 to act as a print server that would have other wise been garbage!
[ Parent | Reply to this comment ]
your tutorial is very clear and so easy that a newbe like me can follow it.
really thanks
Bolth
[ Parent | Reply to this comment ]
My first Linux experience dates all the way back to 1994 but I have not used Linux for a very long time so I recognize almost nothing except bash, hehe.
Your information was really valuable, thank you for taking time and sharing your experience.
Regards
Henrik
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
If its not helpful to any other person, or if he thinks this guide is not good please write one of your own which is understandable to everyone who wants to use linux in home or small office setups.
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
I spent 3 days trying to set up a networked printer on a Centos 5 system and was near to giving up when I found this page.
Worked a treat!
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]