If you’re dealing with a cross-platform network—one that includes Windows and perhaps Mac boxes as well as Linux workstations and servers—you’re naturally interested in making network services available to everyone. In part 1 of this two-part series, you learned how to provide printing services to all your Linux workstation users. In this installment, you’ll learn how to bring Microsoft Windows 95/98/NT/2000 users into the picture. You’ll do so by modifying your Samba configuration so that a local Linux printerŸone that’s attached to the Samba serverŸbecomes available to Windows users throughout your network.

Please note that I’m assuming you’ve installed and configured Samba successfully for file sharing between Linux and Windows systems. If you haven’t yet installed and configured Samba, or if you’ve had trouble getting Samba working correctly, see “Get Samba running,” parts 1 and 2.

This Daily Drill Down also assumes that you’ve successfully installed a printer on the system that’s serving Samba. For more information on getting your printer up and running, see part 1 of this series and ”Linux network printing made easy.”

Configuring Samba to share local printers
Before proceeding, make sure you have Samba running happily so that Windows users can see the Samba server (and their home directories on the Linux server) in their Network Neighborhood lists. I’ll show you how to modify /etc/smb.conf so that a printer attached to the Samba server becomes available to Windows users on the network.

To configure /etc/smb.conf to share a local printer, first make sure the printer is working under Linux. (Sorry, I know I’m repeating myself, but you really need to do this before going on.) Next, install the same printer on one of the Windows clients. To do so, you’ll need the printer’s Windows installation disk. (If you don’t have the disk, note that Windows offers native support for many printers, so you may get away with not having the disk.) To begin installing the printer, click Start, choose Printers, and double-click Add Printer.

In the Add Printer wizard, follow the on-screen instructions until you reach the point in the printer installation process where you select the printer name from a list. Important: Write down the exact name of the printer—and don’t forget capitalization (the names are case-sensitive). For example, the name that Windows uses for an Epson Stylus 740 printer is EPSON Stylus COLOR 740.

Complete the installation and reboot Windows, if necessary. On the Samba server, log in as the root user or superuser, start a text editor, and open /etc/smb.conf. In the [global] section, locate the line that begins with printcap name. If you want to make all the local printers available to Windows users, uncomment this line and the next, if necessary, or add them if they aren’t in the file:
printcap name = /etc/printcap
load printers = yes

Don’t uncomment these lines (or add them) if you want to make certain printers available rather than all of them. Note that Samba assumes you’re using the default print system on most Linux systems, which is derived from BSD. If you’re using a different printing system, locate the line that begins with printing and change the default setting (bsd) to the print system used by your Linux distribution. Options include sysv, plp, lprng, aix, hpux, and qnx. If you’re not sure which print system your Linux distribution uses, check your documentation—but it’s almost certainly bsd.

Next, to make all the local printers available—that is, all the printers listed in /etc/printcap—add the following service entry at the end of /etc/smb.conf:
  writable = no
  path = /tmp
  printable = yes

To make just one of the local printers available, add an auto services line to the [global] section of smb.conf. This line specifies the name of the printer, as defined in /etc/printcap, that you want to make available. The following line makes the default printer (lp) available:
auto services = lp

Also, create a printer definition like the following, and add it to the [services] section (at the end of /etc/smb.conf):
 printable = yes
 comment = Epson Stylus (Color)
 public = yes
 writable = no
 browseable = yes
 printer driver=EPSON Stylus COLOR 740

The above defines a printer named lp. This name must match the name given in the auto services line, and it must also match the printer’s name (or an alias of the printer’s name) as defined in /etc/printcap. Note that the printer driver line requires that you enter the printer information exactly as it’s known to Windows (here, EPSON Stylus COLOR 740, with the capitalization pattern reproduced exactly).

At this point, save /etc/smb.conf. Exit the text editor, and then restart Samba. To do so, type /etc/init.d/rc.d/smb restart and press [Enter].

Checking the installation
Check your work by going to one of the Windows workstations. Log on with the user’s Windows networking username and password, double-click Network Neighborhood, and determine whether the Samba printer shows up. When you right-click and choose Install, you’ll see the Printer Setup dialog box. Because the printer’s name is defined in a way that Windows recognizes, the user won’t have to page through the lengthy list of printer brands and models to begin the installation process. However, the user will still need the installation disk that came with the printer, or the Windows disk if the printer is one of those natively supported by Windows.
A Samba option called printer driver location enables you to specify the location of the printer driver software. Although it’s possible to use the option to serve the printer drivers and associated files from a shared Linux directory, this option doesn’t work with many printer drivers, and you may be violating the publisher’s license by making the software available on a network.
Troubleshooting Samba printing problems
If printing works normally on your Linux system but print services aren’t accessible from Samba, log in as superuser and use a text editor to open /etc/smb.conf. Review your typing carefully. Run testparm /etc/smb.conf and study the output carefully for signs of errors. Make sure /dev/null is writable by all users (to find out, type ls -l /dev/null and look at the permissions). Samba uses /dev/null to discard unneeded print output. If it is not writable by all users, log in as superuser, type chmod a+w /dev/null, and press [Enter]. If your PostScript printer spews out PostScript code instead of graphics, add postscript = yes to the printer’s definition in /etc/samba.conf.

Cross-platform printing horizons
In this Daily Drill Down, you’ve learned how to make printers connected to a Linux system available to Linux and Windows users throughout your network.

Bryan Pfaffenberger, a UNIX user since 1985, is a University of Virginia professor, an author, and a passionate advocate of Linux and open source software. A Linux Journal columnist, his recent Linux-related books include Linux Clearly Explained (Morgan-Kaufmann) and Mastering Gnome (Sybex; in press). His hobbies include messing around with his home LAN and sailing the southern Chesapeake Bay. He lives in Charlottesville, VA. If you’d like to contact Bryan, send him an e-mail.

The authors and editors have taken care in preparation of the content contained herein, but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions. No liability is assumed for any damages. Always have a verified backup before making any changes.