LinuxDevCenter.com

oreilly.comSafari Books Online.Conferences.

We've expanded our Linux news coverage and improved our search! Search for all things Linux across O'Reilly!

Search
Search Tips

advertisement

Listen Print Discuss Subscribe to Linux Subscribe to Newsletters

Network Installation of Windows Printers from Samba

by Carla Schroder, author of the Linux Cookbook
01/13/2005

The combination of Samba and CUPS makes network printing on a mixed Linux/Windows LAN easier than ever. You can share Linux printers with Windows clients, and Windows printers with Linux clients. A Linux/Samba/CUPS printer server is reliable and reasonably simple to set up and maintain.

CUPS without Samba makes an excellent print server for both Windows and Linux clients. But it has one drawback: no network installation of Windows printer drivers. CUPS automatically shares printer drivers with Linux hosts with no extra work on your part; CUPS and Samba together can do the same for Windows hosts. You should have a functioning LAN, all of your Windows hosts in the same workgroup, a Linux machine already running at least one printer with CUPS, and Samba installed and ready to go to work.

When you're first trying this out, it is all right to run the commands as root, like in the following examples. It makes it easier to troubleshoot. But after you get the hang of it, it is better to create a user just for Samba administration chores.

Obtaining Drivers

First off, you need either the CUPS driver for Windows, or the Adobe PostScript driver files. Currently, the CUPS driver is unavailable, though an updated version is supposed to be ready soon.

The Adobe driver package works for all versions of Windows, so you can do without the CUPS drivers. The CUPS driver set is a better choice for Windows NT/2000/XP, because it offers more features and better performance. But the CUPS drivers do not support Windows 95/98/ME; you will still need the Adobe drivers for those. These are the files needed:


CUPS files for Windows NT/2000/XP
	cups.hlp
	cupsdrvr.dll
	cupsui.dll
	
Adobe PostScript files for Windows 95/98/ME	
	ADFONTS.MFM
	ADOBEPS4.DRV
	ADOBEPS4.HLP
	DEFPRTR2.PPD
	ICONLIB.DLL
	PSMON.DLL
	
Adobe PostScript files for Windows NT/2000/XP
	ADOBEPS5.DLL
	ADOBEPSU.DLL
	ADOBEPSU.HLP
	

In this article, we'll use only the Adobe drivers. Download the Adobe driver installer (the English version is called winsteng.exe) to a Windows PC and run the installer (even if you don't have a printer to install), so you can copy the files you need to your Samba server. Look for these two directories after installation: w32x86, which contains the files for Windows NT/2000/XP, and WIN40, which contains the files for Windows 95/98/ME.

The next step is to edit smb.conf to set up a printers and a print$ share. You must use these exact share names, as they are special reserved Samba shares. This is a complete example for wide-open, no-login network printer installations. Of course you will use your own hostnames, workgroup name, and network addresses:


workgroup = familia
server string = %h lan file server (Samba %v)
hosts allow = 192.168.1.
netbios name = windbag

log file = /var/log/samba/log.%m
max log size = 1000
syslog = 0
security = user
passwd program = /usr/bin/passwd %u

passwd chat = *Enter\snew\sUNIX\spassword:* %n\n *Retype\snew\sUNIX\spassword:* %n\n .
load printers = yes
printing = cups
printcap name = cups

[printers]
   comment = All Printers
   browseable = no
   path = /tmp
   printable = yes
   guest ok = yes
   public = yes
   writable = no
   create mode = 0700
   printer admin = root

[print$] 
   comment = Printer Drivers 
   path = /var/lib/samba/printers
   browseable = yes
   read only = yes
   guest ok = no
   write list = root

Save your changes and run the testparm command. When it says your smb.conf is free of errors, restart Samba:

# /etc/init.d/samba restart

Make sure there is a Samba root user:

# smbpasswd -a root
New SMB password:
Retype new SMB password:

Now copy the WIN40 and w32x86 directories to /usr/share/cups/drivers. Make sure that the Adobe filenames are all uppercase. If you use the CUPS drivers, they must be lowercase.

Run this command to ensure that CUPS is the printer back end for Samba:

# ln -s `which smbspool` /usr/lib/cups/backend/smb

Note that those are backticks, not apostrophes.

Copying the Drivers

Now it's time to use cupsaddsmb to export all of the installed CUPS printers to Samba. These command options assume that CUPS, Samba, and all of the drivers are on the same machine:

# cupsaddsmb  -U root -v -a
Password for root required to access localhost via SAMBA:
....
Running command: rpcclient localhost -N -U'root%1234' -c 'setdriver hp6L hp6L'
Succesfully set hp6L to driver hp6L.

Use your Samba password. You should see bales of output fly by, and the last two lines should resemble the example above. The last thing to do is edit smb.conf one more time. Change security = user to security = share, and then restart Samba. There may be a more elegant way to do this; the problem is you need user-level security to enable root to log in to Samba and run cupsaddsmb. But for users to install network printers without requiring Samba accounts, you need share-level security.

You should now be able to go to any Windows PC on your Samba LAN and install printers over the network, and Samba will automatically download the drivers.

Linux Printer Server

This is a great way to build a dedicated Linux print server. You can fine-tune access to printers any way you like with the usual Samba accounts and access controls. Use an old Pentium--don't clutter landfills; there's lots of life in those old PCs. Connect several parallel port printers to a single printer server by using PCI parallel expansion cards. USB printers are even easier and cheaper--a four-port USB hub costs around $20.

Resources

  • See the following man pages:
    cupsaddsmb (8)
    smb.conf (5)
    smbpasswd (5)

  • Chapter 23 of the Linux Cookbook has recipes for using Samba as a file server, for a peer network, for a domain controller, and all kinds of printing scenarios. Chapter 14 (free sample chapter!) covers printing with CUPS, including how to build a printer server for Windows without Samba.

  • Chapter 19 of The Official Samba-3 HOWTO and Reference Guide covers printing in extreme detail. See the Samba list archives for solutions to almost any problem.

Linux Cookbook

Related Reading

Linux Cookbook
By Carla Schroder

Table of Contents
Index
Sample Chapter

Read Online--Safari
Search this book on Safari:
 

Code Fragments only

Carla Schroder is a self-taught Linux and Windows sysadmin and the author of the Linux Cookbook.


Return to the Linux DevCenter.


Comment on this article
You must be logged in to the O'Reilly Network to post a talkback.
Post Comment
Full Threads Oldest First

Showing messages 1 through 2 of 2.

  • relative ease
    2005-08-24 19:46:38  noobtinker [Reply | View]

    I had my smb.conf file configured prior to when I installed the adobe postscript driver package.

    Through the driver installation wizard it automatically setup the printer and printed a test page. In my case the extra steps after downloaded the package and running it were uneeded. Perhaps I'm missing something?
  • CUPS 1.1.21 or higher
    2005-03-24 19:22:33  lingo.chen [Reply | View]

    See http://www.cups.org/newsgroups.php?s4156+gcups.general+v4163+T0

    It seems CUPS change to the user space drivers, so the Win2000, XP, 2003, use the driver set of

    ps5ui.dll
    pscript.hlp
    pscript.ntf
    pscript5.dll

    Note: the name is in lower case.


Tagged Articles

Post to del.icio.us

This article has been tagged:

samba

Articles that share the tag samba:

Inside Samba: Windows Sharing for the Mac (45 tags)

Network Installation of Windows Printers from Samba (16 tags)

FreeBSD Access Control Lists (3 tags)

View All

linux

Articles that share the tag linux:

Managing Disk Space with LVM (74 tags)

Use Your Digital Camera with Linux (60 tags)

mdadm: A New Tool For Linux Software RAID Management (59 tags)

Asterisk: A Bare-Bones VoIP Example (43 tags)

View All

cups

Articles that share the tag cups:

Network Installation of Windows Printers from Samba (9 tags)

View All

printing

Articles that share the tag printing:

Printing XML: Why CSS Is Better than XSL (26 tags)

Network Installation of Windows Printers from Samba (7 tags)

Printing Directory Listings (2 tags)

PDF Processing with Perl (2 tags)

View All

windows

Articles that share the tag windows:

Rolling with Ruby on Rails (57 tags)

Best Windows Admin Downloads (54 tags)

The Ultimate Free Windows Toolkit (31 tags)

Inside Samba: Windows Sharing for the Mac (28 tags)

Automating Windows Applications with Win32::OLE (27 tags)

View All

Sponsored Resources

  • Inside Lightroom
Advertisement

Sponsored by:

O'Reilly Media

©2009, O'Reilly Media, Inc.
(707) 827-7000 / (800) 998-9938
All trademarks and registered trademarks appearing on oreilly.com are the property of their respective owners.
About O'Reilly
Academic Solutions
Authors
Contacts
Customer Service
Jobs
Newsletters
O'Reilly Labs
Press Room
Privacy Policy
RSS Feeds
Terms of Service
User Groups
Writing for O'Reilly
Content Archive
Business Technology
Computer Technology
Google
Microsoft
Mobile
Network
Operating System
Digital Photography
Programming
Software
Web
Web Design
More O'Reilly Sites
O'Reilly Radar
Ignite
Tools of Change for Publishing
Digital Media
Inside iPhone
O'Reilly FYI
makezine.com
craftzine.com
hackszine.com
perl.com
xml.com

Partner Sites
InsideRIA
java.net
O'Reilly Insights on Forbes.com