Sharing Printers from Ubuntu to Windows (focus on Windows 7 and Ubuntu 9.10 Karmic)

We’re going to take the easy way, it’s a home network and doesn’t need industrial security.  If you’re the type of person that wants to go above and beyond, just for the experience, I’m sure a quick *sic* read through the Samba configuration docs will point you in the right directions.  There is plenty of Enterprise level documentation out there for Ubuntu.

This detail will primarily focus at people who want to *try* Ubuntu and may be looking at moving from Windows.  I am not going to assume a lot of experience with the command line, but there is a little bit that I did to make it work.  Here is a critical note with any linux OS, back up any file before you edit it.  You can then always go back to the pristine/working file and start over if you need to.  System configurations vary, as to versions of Ubuntu – so your mileage may vary with these instructions – it goes without saying that you should understand what you are doing BEFORE you do it, I’ll do my best to explain but you are responsible for your computer and the results, not me.

The idea here is that anyone who can access my local network can print.  This configuration is probably not ideal for file share security, but I generally don’t need that at home – so I’m comfortable with this setup. (for now)

First of all, the printer must be connected to your Ubuntu machine.  The printer can be networked (has it’s own IP) or USB; maybe even parallel (ugh) if you still have one of those.

Samba typically comes pre-installed with Ubuntu Karmic – but if for some reason you opted to not included it, here is the installation instructions.

sudo apt-get install samba

Easy, right?

Most people that use Windows are more familiar with a graphic interface than they are with the command line.  So it’s a good idea to also install graphical tool to see what’s happening.  This tool can help you see what your configuration looks like, in a more compartmentalized manner.

sudo apt-get install system-config-samba

Once the install completes, you can find this little app under System->Administration

We’re going to enable guest access in Samba.  This is inherently less secure than user-based authentication, so we’ll configure Samba by setting it so that only the local area network can access it.

The majority of Samba configuration is contained the /etc/samba/smb.conf file.  So we’ll start by backing up the current version.

sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.backup

I typically put the date of the backup as part of the name.  This generally will give me several options as I work through this.  Never overwrite an existing backup – if you already have a backup with that name, use something to differentiate it.  So the last part of the command might be /etc/samba/smb.conf.backup.03212010

Once you have done this, you want to edit the [global] section of smb.conf

How you edit it is up to you.  I used to use a command line tool called vi for a long time, but have started using gedit, as it is much easier to use.  I’ve personally found that editors are something of a religious debate in the linux community – so you can substitute whatever you want in place of gedit.

sudo gedit /etc/samba/smb.conf

Once you are in the editor, scroll to the [global] section and look for the following lines.  They may have a # or ; at the start of the line, which means they are commented out.  If the lines to not exist, just type the full line in.

interfaces = lo eth0
bind interfaces only = true

Edit this line in the [global] section to enable guest access in Samba (if the line isn’t there, add it):

security = share

Now, we’re going to set up the printer share.  Most of this should already exist in your smb.conf, you’ll just need to scroll down and verify that it looks right.

Go to the [printers] share definition and verify/change it so that it looks like the following:

comment = All Printers
browseable = no
path = /var/spool/samba
printable = yes
guest ok = yes
read only = yes
create mask = 0700

Once you have done this, save the file and exit

Now we need to restart Samba in order for the change to take effect.

sudo /etc/init.d/samba restart

Configuration Windows is not as straight forward.  Coming from a Windows background myself, I found this to be less than intuitive.  Connecting Windows to any other operating system seems to vary depending on your SP level, what OS you are trying to connect to and in a few cases, the time of day.

Some things that didn’t work for me.
Using the Add Printer Wizard from the Control Panel
Creating a TCPIP Port and adding the printer manually

Here is what worked.
First off, you have have attempted to add the printer using any of the above methods, reboot the Windows computer.  I found that even my right solution didn’t work until I did.  Of course, this should come as no surprise, the fix for most Windows issues is a full reboot.

Open your Windows Explorer, not Internet Explorer or alternately, you can click the “Start” button and then select Run.

In the run box type \\x.x.x.x  where x.x.x.x is the IP Address of your Ubuntu computer and then press enter.

You can get the IP by opening a terminate and typing ifconfig

Once you press enter, the computer may seem to hang – Don’t Panic.  It does seem like connecting to the Ubuntu computer takes a little time.  I believe the reason is that unlike Windows where the shared information is always broadcast, Samba and CUPS (the printer application in Ubuntu) refreshes this on an interval.  My experience has been that within 30 – 60 seconds the window will appear with the printer listed.

Right click on the printer and select Connect.

Now a key difference here is that if you were connecting to a printer on a Windows box, you would download the driver from that box and install it on your computer.  With Ubuntu printer sharing the printer, you will need to either select the printer from the Windows driver list or download the driver from your manufacturer website and use the “Have Disk” option.

Once you complete this your printer *should* work.  I am working on compiling a list of issues that I run into relating to printing and will update this post periodically to include the fixes I find that work.

Issue:  No Printers Show Up in Windows When I Enter the IP (Ubuntu 9.10 Karmic)
Go into your System->Administration->Printing
From the menu at top of the Printers window, select Server->Settings
Make sure you have the following settings checked
– Show printers shared by other systems
– Publish shared printers connected to this system
– Allow printing from the Internet

You can check other options if you want to, but do your research first.

Next, Right Click on the printer you want to have shared, make sure the boxes next to enabled and shared are checked (it’s not really a check mark, but it will not be grey when it’s on)

Once you have done that, Right Click on the printer again and select properties.
Under Access Control verify that the option to Allow Printing for everyone except these users is selected.

Most of the above information can be found on a multitude of forums – if you run into problems, do some Google searches on ubuntu samba sharing printers with windows.  Google any errors you receive.  If you run into anything interesting, please feel free to send it to me, I’ll update this.

This entry was posted in System Administration, Ubuntu and tagged , , , , . Bookmark the permalink. Follow any comments here with the RSS feed for this post. Post a comment or leave a trackback.

Leave a Reply

%d bloggers like this: