CinnamonPirate.com

Aug 16, 2007

How To: Ubuntu and Windows printers

BY DERRICK SOBODASH

GETTING THE office printer to work from Ubuntu has been an ongoing struggle for me since March. Yesterday, I finally figured it out. Sadly, this would have been so, so much easier if someone had just taken the time to explain how the hell Samba works with CUPS, the Linux print server.

First off, you will need access to a Windows computer that can already access the printer. You will need the IP address of the printer — or the machine it’s connected to — and the name of the shared printer. A make and model won’t hurt either.

If you enter an IP address in the run dialog every time to mount the printer thanks to a settings killing app like what is on our work computers, you already have one step down. If not, right click the mounted printer in your Windows Printer folder and select properties. Click through the tabs until you see where this printer location is really going. Then you can click Start->Run and enter \\IP_YOU_FOUND_HERE and click run. Look for the printer in the shares that come up, and copy the name down exactly.

Next, open up Ubuntu’s Printer settings and configuration. It will be in Applications->Settings on an Xubuntu setup. Click on “New Printer” and follow the wizard. In the second step, pick “WIndows Printer via SAMBA,” and for the address, write IP_YOU_FOUND_HERE/PRINTER_NAME. That’s it, unless you need a special port or login information–most setups should not require this. Click next and finish out the wizard.

When you are done, you’ll see a new entry under Local Printers in your Printer Configuration dialog. Click it, then click the Print Test Page button. If a test page comes out, you are in good shape. You may want to click “Make Default Printer” unless you have another that you use.

The last step is to hack your /etc/hosts file.

“What? Why do I need to do that?”

Because since Edgy, someone has royally fucked the hosts file, and it causes several printing applications which depend on 127.0.0.1 to become totally b0rked.

(Incidentally, I find it very funny that Firefox considers “borked” to be a spelling error, but “b0rked” is perfectly acceptable. Hmmm.)

Chances are, your file currently looks like this:

127.0.1.1 YOUR_HOSTNAME
127.0.0.1 localhost

# The following lines are desirable for IPv6 ...

Evince does not seem to like it when the first line of the file is 127.0.1.1 and your hostname. As far as I can tell, it is something to do with it using generic GNOME printing code. Yes, this is shit programming on GNOME’s part, and I cannot begin to guess why they try to directly steal the first entry of the file instead of actually parsing it. Based on the HOSTS specification, it should be able to go anywhere at all.

What you need to do is flip the first two lines around so you get:

127.0.0.1 localhost
127.0.1.1 YOUR_HOSTNAME

# The following lines are desirable for IPv6 ...

Save it out and reboot. Alternatively, you could do anything that will make your machine rehash the HOSTS file, but a reboot might be easier.

The ultimate test to see if everything is working fine is running Evince to view an Acrobat PDF or PostScript file. Try printing something to your new printer. If the print button is not grayed out, you are all set.

Enjoy your new Ubuntu printer, and make sure to kill more trees while you have access to that nice, office Laser printer.

After all, a tree would kill you if it had the chance.

Leave a response