The easy way to print from Linux to Windows

The usual way printing works on Linux is by connecting your printer directly to your system, or printing through IPP. But what if you need to print to a printer connected to a Windows system?

Here is how to get it working while keeping fuss to a minimum. Once again, these instructions are made with Debian Squeeze in mind, so adjust them if you’re using a different distribution. I used Windows XP but I believe these instructions should also work for Vista and Windows 7.

  1. In Windows, make sure the printer is shared.
  2. Make note of the printer’s share name and the system’s hostname, viewable in System Properties (right-click the My Computer icon).

  3. Install smbclient.
  4. # aptitude install smbclient

  5. In GNOME go to System/Administration/Printing. On the menu bar go to Server/New/Printer. You’ll probably have to provide your root password to continue.
  6. Click “Network Printer”, then select “Windows Printer via SAMBA.”
  7. On the right pane you’ll see a textbox to enter the address for the printer itself. Click Forward.
  8. You have to enter both the Windows hostname and the printer’s share name, so you’d type something like mywindowspc/myprinter. Make sure you get the case right.

  9. It is likely CUPS already has a working driver for your printer, so look for it on the list of drivers. If you want to provide a PPD file or look for another driver, you can also do that.
  10. In my own case there were three available drivers for the printer, so I went with the one marked “recommended” by the wizard.

  11. Assign a printer name, description, and location. You may have to re-enter your root password to save all settings.
  12. Print a test page.

That should do the trick. If it doesn’t work you can try using another print driver. If that still doesn’t work, try looking for a Linux driver for your printer.

The no-bullshit Samba plus Nautilus network shares method.

Here is how to setup Samba and GNOME Nautilus to allow user directory sharing without having to allow root access. These commands are made with Debian in mind, so if you want to use them for your Linux distribution, you’ll have to adapt them.

  1. Install samba and nautilus-share.
  2. # aptitude install samba nautilus-share

  3. Rename your smb.conf to smb.conf.master
  4. # cd /etc/samba
    # mv smb.conf smb.conf.master

  5. Add the following to smb.conf.master somewhere under the [global] stanza using your favorite text editor.
  6. security = SHARE
    usershare allow guests = Yes
    usershare owner only = No

  7. Run the following command:
  8. # testparm -s smb.conf.master > smb.conf

    This tests the samba master configuration file, then outputs the results to the file samba itself will use for its configuration. If it finds errors, it will warn you about them.

    According to the Samba docs, a small smb.conf file improves performance. It also improves readability once you’re familiar with Samba options.

  9. Restart samba.
  10. # /etc/init.d/samba restart

  11. Add your user to the sambashare group. If more people use the system and they need to share files, make sure to add them as well.
  12. # useradd -G sambashare foo

  13. Log out of your user session, then log back in.
  14. On Nautilus, when you right-click directories you will now see a “Sharing options” item. Through this item you can:
    • Share the folder, assigning a share name.
    • Allow read/write access.
    • Enable Guest access, which allows people without a user account on the system to access the share.

This last option is the most useful as people can now get stuff through the network without having to deal with usernames or passwords. Does this make the Linux system behave like a Windows system? Yes, it does.

There is something to be said, however, about the convenience of creating shares without having to muck around the smb.conf.master file whenever you want to make a change.