How-to: Network Printer Sharing

Write tutorials and howtos in here
There are more tutorials here http://community.linuxmint.com/tutorial/welcome
Forum rules
Do not start a support topic here please. Before you post please read this

Re: How-to: Network Printer Sharing

Postby altair4 on Tue Sep 28, 2010 5:17 pm

AbeFreeman,

Edit smb.conf as root:
Code: Select all
gksu gedit /etc/samba/smb.conf

Look for the [printers] share:
[printers]
comment = All Printers
browseable = No
path = /var/spool/samba
printable = yes
guest ok = no
read only = yes
create mask = 0700

and change it to:
[printers]
comment = All Printers
browseable = No
path = /var/spool/samba
printable = yes
guest ok = yes
read only = yes
create mask = 0700

Save the file and restart samba:
Code: Select all
sudo service smbd restart
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.
altair4
Level 15
Level 15
 
Posts: 5516
Joined: Tue Feb 03, 2009 10:27 am

Linux Mint is funded by ads and donations.
 

Re: How-to: Network Printer Sharing

Postby AbeFreeman on Tue Sep 28, 2010 11:19 pm

Printed just fine! Wish the driver had a "draft" option though, but working is working, so I won't complain. I'm puzzled, though, as to why this file didn't get changed when I "published" the printer through the samba (or nautilus, or whatever it was that I was using) GUI. I mean, when there's a GUI that seems like it is doing a certain job, but only does half the job and you have to somehow know the inner workings in order to really do the job..... it's the kind of thing that makes most people steer away from linux. Anyway, I'm sure thankful for the patient support I get through this forum!
User avatar
AbeFreeman
Level 3
Level 3
 
Posts: 143
Joined: Wed Aug 04, 2010 12:36 am

Re: How-to: Network Printer Sharing

Postby altair4 on Wed Sep 29, 2010 8:50 am

AbeFreeman, First, don't change a thing on your configuration as you now have something that works so don't mess with it. These are just my ramblings.

It's most likely the poor way I wrote this HowTo but the problem for you was the way you tried to access the Linux printer.
When you use the "Browse for a Printer" function in the Windows "Add Printer Wizard" you force windows to use Samba. If it works that's great but if it doesn't then the best thing to do is not use Samba. Printing on a Linux system is ultimately controlled by CUPS and the way you get to CUPS remotely is by IPP ( Internet Printing Protocol ). Samba can be used as a pass through to CUPS but it's really an unnecessary overhead and brings with it more complexity.

Although Windows is relatively flexible it how it can access a remote printer it is unnecessarily finicky about how it uses IPP.

If you select "Connect to this Printer" in the Wizard and enter the location is this type of format it should use ipp but sometimes it doesn't work: \\192.168.0.100\LinuxPrinterName

The best way is to use "Connect to a printer on the Internet or on a home or office network" ( or "Add a network, wireless or Bluetooth Printer" in Win7 ) with this type of format:
http://192.168.0.100/printers/LinuxPrinterName
OR EVEN BETTER:
http://192.168.0.100:631/printers/LinuxPrinterName
631 is the ipp port number that Linux uses for the CUPS server.

WinNT, Win2K, and WinXP has ipp built in but Win7 is another story. In Win7 you have to add the "Internet Printing Client" to the base install for this to work but the option to install doesn't exist for Win7 Starter Edition.

I'll review this HowTo and see if I can fix it.
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.
altair4
Level 15
Level 15
 
Posts: 5516
Joined: Tue Feb 03, 2009 10:27 am

Re: How-to: Network Printer Sharing

Postby AbeFreeman on Thu Sep 30, 2010 2:52 am

Since I eventually got windows to "find" the printer by browsing, though, and it still didn't like the linux printer driver, if I had used the "Connect to a printer on the Internet or on a home or office network" option, I would still have the problem of finding a driver that windows was happy with, and have to substitute a generic one, right?
User avatar
AbeFreeman
Level 3
Level 3
 
Posts: 143
Joined: Wed Aug 04, 2010 12:36 am

Re: How-to: Network Printer Sharing

Postby altair4 on Thu Sep 30, 2010 6:55 am

Yes, you have this odd problem that your driver isn't showing up in WinXP and you would still have had that problem. I was responding more to this comment:
I'm puzzled, though, as to why this file didn't get changed when I "published" the printer through the samba (or nautilus, or whatever it was that I was using) GUI. I mean, when there's a GUI that seems like it is doing a certain job, but only does half the job and you have to somehow know the inner workings in order to really do the job..... it's the kind of thing that makes most people steer away from linux.

The "share" and "publish" functions are part of CUPS. The "guest ok" is part of Samba. Two separate systems that must be configured separately. The point of my rambling was that one should try to connect to CUPS more directly without adding the overhead of Samba.
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.
altair4
Level 15
Level 15
 
Posts: 5516
Joined: Tue Feb 03, 2009 10:27 am

Re: How-to: Network Printer Sharing

Postby CycleDude on Mon Oct 04, 2010 10:18 pm

Thanks for your great support and tutorials, Altair.
I'm running a linux mint 9 kde desktop computer with a printer attached and have been trying (with the help of your tutorial, etc) to get my wife's Vista laptop to print to it. I have samba set up so the laptop recognizes my files on the desktop, which is great, but here's the problem.

When I go to 'Network' on the Vista laptop, sometimes the attached printer is visible and sometimes it's not. When it's visible, she can print from Word, etc., to the linux desktop printer. Otherwise she can't.
I think I've finally deduced the problem. When I edit or even open the smb.conf file, after that , the printer shows up on the laptop.

So it must have to do with smbd / nmbd not up and running on startup. Is this perhaps due to the bug you talked about in the boot sequence?

My question is ... what's the best way to ensure smbd is automatically started at boot? I read one of your (I think) responses on how to run a small script with a delay, but not sure that's what's needed here, and didn't want to mess up my boot. This has been a huge source of frustration for me in trying to switch completely into Linux (which I have).
CycleDude
Level 1
Level 1
 
Posts: 2
Joined: Mon Oct 04, 2010 9:29 pm

Re: How-to: Network Printer Sharing

Postby altair4 on Tue Oct 05, 2010 7:07 am

There are 2 bugs ( actually it's more than that ) that has been introduced in Ubuntu ( and thus Mint ) that may be a problem here:

(1) CUPS is starting after samba starts. If you use samba ( or smb in Vista ) then there will be no visible printers listed even though CUPS is fully operational and ready for remote printing.

(2) nmbd is starting before the network is up. If you use Samba then your entire Linux box ( printers and shares ) will be invisible on the network.

Both of these situations have workarounds but you could circumvent the problem entirely by not using Samba. Instead connect to the printer directly from Vista:

Start > Control Panel > Hardware and Sound > Printer > Add a Printer > Add a network, wireless or Bluetooth printer > The printer that I want isn't listed > Select a shared printer by name >

Then in the input box enter the address in one of the following formats:

Code: Select all
\\192.168.0.100\LinuxPrinterName

or
Code: Select all
http://192.168.0.100:631/printers/LinuxPrinterName


If that doesn't work and Samba is the only way then here are the workarounds:

(1) CUPS starting after Samba starts

Edit /etc/init/smbd.conf and change this:
description "SMB/CIFS File Server"
author "Steve Langasek <steve.langasek@ubuntu.com>"

start on local-filesystems
stop on runlevel [!2345]

respawn

pre-start script
RUN_MODE="daemons"

[ -r /etc/default/samba ] && . /etc/default/samba

[ "$RUN_MODE" = inetd ] && { stop; exit 0; }

install -o root -g root -m 755 -d /var/run/samba
end script

exec smbd -F

to this:
description "SMB/CIFS File Server"
author "Steve Langasek <steve.langasek@ubuntu.com>"

start on (local-filesystems and stopped rc)
stop on runlevel [!2345]

respawn

pre-start script
RUN_MODE="daemons"

[ -r /etc/default/samba ] && . /etc/default/samba

[ "$RUN_MODE" = inetd ] && { stop; exit 0; }

install -o root -g root -m 755 -d /var/run/samba
end script

exec smbd -F


(2) nmbd starting before the network is up

Create a script ( this is for Gnome so change gedit to whatever the editor is in KDE ) :
Code: Select all
gksu gedit /etc/network/if-up.d/nmbd

With this content:
Code: Select all
#!/bin/sh
service nmbd start

Save the file and make it executable:
Code: Select all
sudo chmod +x /etc/network/if-up.d/nmbd
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.
altair4
Level 15
Level 15
 
Posts: 5516
Joined: Tue Feb 03, 2009 10:27 am

Re: How-to: Network Printer Sharing

Postby CycleDude on Thu Oct 07, 2010 8:50 pm

Thanks for all your suggestions about the bugs.
I've tried them all, together and individually but with no luck.
However, I did find out what works. And by 'works' I mean the printer on the linux desktop apears on the network on the laptop.
If the printer shows on the laptop, I know my wife can print fairly directly to the bedroom printer.

sudo service smbd restart

Even though smbd is already running after startup, it's only after restart that the printer becomes visible on the laptop network.
So I added the above line to the nmbd script file you suggested and I THINK it now works on startup.
So my script file looks like this: (after using gksu gedit /etc/network/if-up.d/nmbd to open the file)

#!/bin/sh
service nmbd start
service smbd restart

If this doesn't turn out in the long run, I'll see if you have any other suggestions.
But for now this may have solved it. Thanks again for your help!
CycleDude
Level 1
Level 1
 
Posts: 2
Joined: Mon Oct 04, 2010 9:29 pm

Re: How-to: Network Printer Sharing

Postby Lvcoyote on Sun Oct 31, 2010 2:28 am

Just had to chime in here. Until I ran across this thread I was never able to get a printer attached to a Windows7 computer (USB) to work from Linux. I used the Cups method of install and once I got the right address to the printer figured out IT WORKED!!!!!!! You should have seen me jumping for joy at the accomplishment that for a looooooooooong time I was never able to figure out.

Thanks for the awesome tutorial.
ASUS Rampage IV Black Edition, i7 4930K, G.Skill Trident 4X4 GB DDR3 2400, EVGA GTX 780 Classified, Corsair 700D, Corsair HX850W PSU, Samsung 840 Pro 256 GB SSD, Plextor SATA Blu-Ray, Water Cooled CPU and Video Card, Linux Mint 16
User avatar
Lvcoyote
Level 1
Level 1
 
Posts: 30
Joined: Sat Oct 23, 2010 9:39 am

Re: How-to: Network Printer Sharing

Postby msuggs on Wed Jan 26, 2011 6:18 am

Thank you for maintaing this howto, particularly for LMDE users :)

With sharing to OSX users it's slightly different in Snow Leopard. There is no need for the advanced option. Just choose 'IP', then:

Protocol: Internet Printing Protocol
Address: IP address of your Print server
Queue: printers/Linux-Printer-Name

Name: Printer Name
Print using: Select Printer Software - and search for the appropriate driver

Click 'Add'
msuggs
Level 5
Level 5
 
Posts: 882
Joined: Thu Jul 10, 2008 8:25 am
Location: non-local

Re: How-to: Network Printer Sharing

Postby aia832003 on Sun Feb 13, 2011 11:49 am

I have been having the same problem after reinstalling Windows 7 on my Acer One netbook for my wife to use with her new Verizon Iphone. I did manage to find a fix on another forum. Please try the following method.

1. Click Start, click Control Panel and double click Devices and Printers.
2. Click Add a Printer.
3. Select "Add a local printer".
4. Select "Create a new port". Choose "Local Port" as the type of the port.

5. In the box "Enter a port name", type the address as the following format.

\\[IP address of the host computer]\[The Share Name of the printer]

Then click Next.

6. Choose the correct driver in the driver list. If no available driver, click the button Windows Update, wait for the process finishes and then look for the driver again.
7. Finish the installation.
This totally worked for me. This is the settings that worked for me, but the site had more; here's the link: http://social.technet.microsoft.com/For ... 84fdf273f2

Hope this helps others.
aia832003
Level 1
Level 1
 
Posts: 5
Joined: Thu Jun 04, 2009 9:40 pm

Re: How-to: Network Printer Sharing

Postby llogg on Sat Feb 26, 2011 10:53 pm

aia832003 wrote:I have been having the same problem after reinstalling Windows 7 on my Acer One netbook for my wife to use with her new Verizon Iphone. I did manage to find a fix on another forum. Please try the following method.

1. Click Start, click Control Panel and double click Devices and Printers.
2. Click Add a Printer.
3. Select "Add a local printer".
4. Select "Create a new port". Choose "Local Port" as the type of the port.

5. In the box "Enter a port name", type the address as the following format.

\\[IP address of the host computer]\[The Share Name of the printer]

Then click Next.

6. Choose the correct driver in the driver list. If no available driver, click the button Windows Update, wait for the process finishes and then look for the driver again.
7. Finish the installation.
This totally worked for me. This is the settings that worked for me, but the site had more; here's the link: http://social.technet.microsoft.com/For ... 84fdf273f2

Hope this helps others.
Nothing else was working, but this did the trick. My wife thinks I'm king of the nerds again. Thanks.
Intel Pentium Dual 2.00 GHz
2Gb RAM
Linux Mint Cinnamon 14
llogg
Level 3
Level 3
 
Posts: 109
Joined: Sat Feb 12, 2011 6:56 pm

Re: How-to: Network Printer Sharing

Postby llogg on Sun Mar 06, 2011 1:12 am

Help! I screwed up. I had the following setup working:
Printer connected to Mint PC shared with Vista PC with the printer setup in Vista on a local port with the ip address of the printer as the port.

I was trying to follow some instructions on sharing folders from Mint to the same Vista machine and installed the Samba config GUI package. It wasn't working so I tried to uninstall the GUI package but I think I uninstalled all of Samba. I have since reinstalled all the Samba packages I could find. I followed the instructions here, but cannot get the thing to print from Vista. Any help?
Intel Pentium Dual 2.00 GHz
2Gb RAM
Linux Mint Cinnamon 14
llogg
Level 3
Level 3
 
Posts: 109
Joined: Sat Feb 12, 2011 6:56 pm

Re: How-to: Network Printer Sharing

Postby altair4 on Sun Mar 06, 2011 9:45 am

llogg wrote:I was trying to follow some instructions on sharing folders from Mint to the same Vista machine and installed the Samba config GUI package. It wasn't working so I tried to uninstall the GUI package but I think I uninstalled all of Samba. I have since reinstalled all the Samba packages I could find. I followed the instructions here, but cannot get the thing to print from Vista. Any help?

What Samba config GUI did you install? If it was something like gadmin-samba you likely have an incomprehensible mess in smb.conf that a reinstall of samba won't fix.

Can you post the link to the instructions you were following? ( Lord, I hope it wasn't one of mine :wink: )

If you installed all the Samba packages "you could find" then you likely installed Samba4 which is experimental alpha level software so you need to remove it.

If you were using a \\[IP address of the host computer]\[The Share Name of the printer] you probably weren't using samba anyway but ...

Why not post the output of the following command to see how samba is configured:
Code: Select all
testparm -s
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.
altair4
Level 15
Level 15
 
Posts: 5516
Joined: Tue Feb 03, 2009 10:27 am

Re: How-to: Network Printer Sharing

Postby llogg on Sun Mar 06, 2011 5:17 pm

testparm -s results:
Code: Select all
Load smb config files from /etc/samba/smb.conf
rlimit_max: rlimit_max (1024) below minimum Windows limit (16384)
Unknown parameter encountered: "hosts equiv"
Ignoring unknown parameter "hosts equiv"
Processing section "[printers]"
WARNING: The "printer admin" option is deprecated
Processing section "[DEFAULT PRINTER]"
WARNING: The "printer admin" option is deprecated
Processing section "[PUBLIC]"
Processing section "[home_directories]"
Processing section "[matt]"
Loaded services file OK.
WARNING: You have some share names that are longer than 12 characters.
These may not be accessible to some older clients.
(Eg. Windows9x, WindowsMe, and smbclient prior to Samba 3.0.)
Server role: ROLE_STANDALONE
[global]
   netbios name = MATT
   interfaces = lo, eth0
   bind interfaces only = Yes
   null passwords = Yes
   username map = /etc/samba/smbusers
   hostname lookups = Yes
   printcap name = CUPS
   guest ok = Yes
   hosts allow = 192.168.0.0/255.255.255.0, localhost
   hosts deny = All

[printers]
   comment = All Printers
   path = /var/spool/samba
   printer admin = root
   printable = Yes
   browseable = No

[DEFAULT PRINTER]
   comment = Brother HL-5370DW series
   path = /var/spool/samba
   printer admin = root
   read only = No
   printable = Yes

[PUBLIC]
   path = /HOME/PUBLIC
   read only = No
   create mask = 0766

[home_directories]
   path = /home/%U
   valid users = %U, root
   read only = No

[matt]
   path = /home/matt
   read only = No

Also, when I uninstalled samba the first time it told me to do an autoremove command to get rid of some related unnecessary items, which I did, but I did not write down what they were. Could this be why the printer is no longer working? If so, does anyone know how I can find out what those files were and get them back? Because it was done through the terminal and not synaptic, it does not show up in the history kept in synaptic.
Intel Pentium Dual 2.00 GHz
2Gb RAM
Linux Mint Cinnamon 14
llogg
Level 3
Level 3
 
Posts: 109
Joined: Sat Feb 12, 2011 6:56 pm

Re: How-to: Network Printer Sharing

Postby altair4 on Sun Mar 06, 2011 5:48 pm

If you have any samba4 packages installed remove them before start the following process:

(1) Make sure the following file exists: /usr/share/samba/smb.conf

(2) Make a backup of your current smb.conf
Code: Select all
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.bak

(3) Copy the default:
Code: Select all
sudo cp -a /usr/share/samba/smb.conf /etc/samba/

(4) Correct one mistake in the new one:
Find the line: encrypt passwords = false

and change it to: encrypt passwords = true

(5) Restart samba
Code: Select all
sudo service smbd restart


You've just reset yourself to the factory fresh smb.conf.
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.
altair4
Level 15
Level 15
 
Posts: 5516
Joined: Tue Feb 03, 2009 10:27 am

Re: How-to: Network Printer Sharing

Postby llogg on Sun Mar 06, 2011 6:13 pm

Thanks for your help altair. I assume I needed to make the change to the /etc/samba copy of the file since changing it in the /usr/share/samba file didn't change anything when I ran testparm -s again. Also, I did not find "encrypt passwords = false" but rather "encrypt passwords = no" and changed this to "yes" instead of "true". Here is what running testparm -s returned after making this change:
Code: Select all
Load smb config files from /etc/samba/smb.conf
rlimit_max: rlimit_max (1024) below minimum Windows limit (16384)
Processing section "[printers]"
Processing section "[print$]"
Loaded services file OK.
Server role: ROLE_STANDALONE
[global]
   server string = %h server (Samba, Ubuntu)
   map to guest = Bad User
   obey pam restrictions = Yes
   pam password change = Yes
   passwd program = /usr/bin/passwd %u
   passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .
   unix password sync = Yes
   syslog = 0
   log file = /var/log/samba/log.%m
   max log size = 1000
   dns proxy = No
   usershare allow guests = Yes
   panic action = /usr/share/samba/panic-action %d

[printers]
   comment = All Printers
   path = /var/spool/samba
   create mask = 0700
   printable = Yes
   browseable = No

[print$]
   comment = Printer Drivers
   path = /var/lib/samba/printers

Of note the encrypt password line between "server string" and "map to guest" lines has disappeared, rather than going from no to yes. Is this the expected behavior?

Edited to Add:
After making the force user = mylinuxmintusername change in your excellent file sharing tutorial thread I can print from the Vista machine to the printer connected to the Mint computer and I can share files between the two computers. Thanks for your help. I'll try not to screw it up again.
Intel Pentium Dual 2.00 GHz
2Gb RAM
Linux Mint Cinnamon 14
llogg
Level 3
Level 3
 
Posts: 109
Joined: Sat Feb 12, 2011 6:56 pm

Re: How-to: Network Printer Sharing

Postby ddalley on Wed Apr 06, 2011 8:56 pm

Recent Debian releases of LinuxMint don't seem to be set up for networked printing, so it would be advantageous for users for these distributions to be modified going forward.

I just configured LXDE tonight to handle this and I think all it really needed was to have the smbclient installed. I installed a few other things beforehand, too, so I am not 100% certain which one allowed it to work.

Now I have to do it with Debian and probably Xfce, when I get that one installed.

Thanks for this tutorial, Altair4!
ddalley
Level 4
Level 4
 
Posts: 272
Joined: Sun Mar 15, 2009 4:25 am
Location: Toronto, Canada

Re: How-to: Network Printer Sharing

Postby altair4 on Tue Aug 14, 2012 1:05 pm

A workaround for the following error message if you are using Ubuntu 12.04, Xubuntu 12.04, or Mint13-Gnome:
"Windows cannot connect to the printer. Either the printer name was typed incorrectly or the specified printer has lost its connection to the sever".


On the machine that has the printer attached to it:

[1] Add a line to the [printers] section in smb.conf:
[printers]
comment = All Printers
browseable = hdhd
path = /var/spool/samba
printable = yes
guest ok = yes
printer admin = @lpadmin
; read only = yes
create mask = 0700

And add one more to the global section right under the workgroup line:
# Change this to the workgroup/NT-domain name your Samba server will part of
workgroup = WORKGROUP
force user = altair

Change altair to your own login user name

[2] Run the following commands just to make sure everything is running in the right order:
Code: Select all
sudo service cups restart
sudo service smbd restart


[3] Then run the following command:
Code: Select all
sudo rpcclient localhost

The prompt changes to "rpcclient $>. At that point enter the following command
Code: Select all
enumprinters

What you may get is something like this:
flags:[0x800000]
name:[\\LOCALHOST\]
description:[\\LOCALHOST\,,HP970-Photo]
comment:[HP970-Photo]

Note that the comment and the description have the correct printer name but "name:" only shows \\LOCALHOST.

CUPS supplies the printer name to samba and samba in turn displays that name to Windows but when Windows tries to connect to that printer all it sees is \\LOCALHOST not a printer. To fix this:

While in the terminal at the rpcclient $> prompt enter the command like this example:
Code: Select all
setprintername HP970-Photo HP970-Photo

You should get the following if this was successful:
rpcclient $> setprintername HP970-Photo HP970-Photo
Success in setting printername.

Just as a check run the enumprinters command again and you should get this:
flags:[0x800000]
name:[\\LOCALHOST\HP970-Photo]
description:[\\LOCALHOST\HP970-Photo,,HP970-Photo]
comment:[HP970-Photo]

Now it has a name that Windows can deal with.

By the way this also fixes the problem of a Linux client trying to access a printer through Samba and being asked repeatedly for a username and password.

To escape the prompt just enter exit then hit enter:
rpcclient $> exit


Now see if the client machine can connect to the samba printer.
Last edited by altair4 on Mon Aug 27, 2012 4:16 pm, edited 5 times in total.
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.
altair4
Level 15
Level 15
 
Posts: 5516
Joined: Tue Feb 03, 2009 10:27 am

Re: How-to: Network Printer Sharing

Postby ddalley on Tue Aug 21, 2012 11:38 pm

[strike]rpcclient $> enumprinters
No printers returned.

Didn't work with a SAMBA printer.[/strike]

:x SAMBA isn't running in this install!
Please make all LM installs consistent.
ddalley
Level 4
Level 4
 
Posts: 272
Joined: Sun Mar 15, 2009 4:25 am
Location: Toronto, Canada

Linux Mint is funded by ads and donations.
 
PreviousNext

Return to Tutorials / Howtos

Who is online

Users browsing this forum: tfernandes and 15 guests