Wednesday, 24 October 2007 19:33

The ever cunning Linux dances the Samba

TCP/IP, the lingua franca of the Internet, was developed on UNIX systems. As such, Linux has benefited from this heritage by naturally fitting in to any TCP/IP network. Yet, sometimes you still need to deal with computers whose operating system has distinctly non-TCP/IP legacy networking components. A case in point is sharing your printer to Windows users.

And this is something reasonable to do; sharing a single printer among all the computers in your household or workplace – irrespective of their operating system – can save money and add convenience. Although Microsoft made TCP/IP the standard network protocol from Windows 2000 on, its Windows operating systems still use a proprietary protocol – SMB, or Server Message Block – to communicate amongst its sibling systems. (TCP/IP stacks were available right back to Windows 3.1 and DOS, but these were not the default protocol until Microsoft made TCP/IP a fundamental part of Active Directory.)

Not to worry; Linux is multi-lingual and, as usual, gobbles up interoperability in its stride. It provides an SMB implementation which is named Samba and which can make any printers attached to your Linux computer be visible to, and usable by, the Microsoft Windows computers on your network. Here’s how to get it going.

Note first, your printer must work under Linux already. If it doesn’t print on the Linux system it is directly plugged into then there’s no point attempting to share it. Unfortunately, actually getting printers to print in the first place is a big and complex issue and not our topic for this time. Suffice it to say, if you can’t yet print – or are still choosing a printer to purchase – be sure to check out the Linux Foundations open printing guide. Here you’ll find lists of printer models known to have Linux drivers, as well as downloads for any drivers not included as packages for your flavour of Linux.

Make sure your printer is plugged in and powered on and that your Linux machine has detected it and can send test pages. Use the Printer Configuration applet to correct any problems or install new drivers.

Also, use the Printer Configuration applet to adjust server settings; several check boxes will show with options ranging from auto-detecting printers shared by other computers through to letting people cancel someone else’s print jobs and gathering debugging information. The one we’re keen on, though, is “Share published printers connected to this system” or words of similar effect on your distribution. Check the box for this option – and the word "check" is bad here; tick or cross the box; don't just visually inspect it.

Click on the name of each specific printer listed under the Local Printers section of the applet. You’ll also find a Shared check box here. Make sure this is also checked. (And, if you have multiple printers and only want to share one or some, be sure the ones you don’t want to share do not have this box checked.)

It’s now time to get Samba up and running. Fire up the package management tool for your distribution. For instance, under Ubuntu you might click System, Administration, and Synaptic Package Manager. Under Fedora you would click Applications then Add/Remove Software. You might also use other means like the command sudo apt-get install samba smbfs.

If you use the apt-get command above, Samba will install automatically. If you are using a GUI tool, locate the Samba package and select it, then instruct the tool to download and install it.

Note importantly that if you have SELinux operating you will need to update its configuration item so that it allows Samba to share files and directories.

You must configure Samba before it actually does anything. Call up the freshly-installed Samba server settings window. Click the Preferences, Server settings menu. You will be prompted to give the name of your Windows workgroup along with an optional description. Click OK to apply your changes and close the dialog box.

Next, start the Linux service configuration window. Here, you can control what runs when the system boots as well as start or stop any individual service. You want to do two things here: firstly, start Samba running right now, and secondly have it auto-start when your computer kicks in.

Find the smb service item; click Start and select the checkbox next to it. The smb service actually consists of two separate services. The first of these is smbd, which is a daemon process that handles client SMB connections to your system, and the second is nmbd, which is a daemon process to control the advertising of shared devices over your network.

By now, Samba is loaded and running. Unfortunately it’s still not usable yet; you now need to open the Firewall applet. Here, you want to have your firewall permit SMB traffic to enter your system. Locate the Samba entry in your firewall and mark it as a trusted service. Linux will now allow SMB traffic from network clients to successfully make it through to your computer.
There is now one final step: although remote computers can send SMB traffic, nobody has yet been authorised to do so. Edit the file /etc/samba/smb.conf using your favourite text editor; remember to run it using the sudo command or from within a superuser account, because you will need to be able to write modifications back to the file system.

The modifications you wish to make will provide granular control over who may print. There’s two real options: one is to make unique user accounts for each person on your network, or alternatively, if you are just enabling a home printer in a family environment you might simply permit anyone to print to the shared printer. Either way, you do it through /etc/samba/smb.conf.
To let just anyone print, edit that file, and locate the [printers] section. Find the commented-out line “; guest ok = no” and change it to “guest ok = yes”. (Note, the semicolon has been removed as well as the no changing to a yes.) Now your network guests may print without authentication required.

Alternatively, if you prefer to set up accounts per user, instead edit that file and locate the authentication section. Find the line, also commented out, which reads “; security = user”. Just as with above, remove the semicolon to leave “security = user”. Add a new line directly below it, which reads username map = /etc/samba/smbusers. This line instructs Samba to find the list of permissible users contained within the file /etc/samba/smbusers.

Use the command sudo smbpasswd –a <username> to set up users for Samba. Modify <username> for the username you are setting up. Next, use a text editor to add that username to the end of the /etc/samba/smbusers file in the form <username> = “<username>”. This syntax seems cryptic, but the reason is that you may have a different username within Linux than you do on your Windows systems. If you keep the usernames consistent across platforms you should find a minimum of fuss; Windows will attempt to provide the credentials of the currently logged-in user when it encounters a new file share on the network. If you are confident about what you are doing then you may opt for different details, but you may find Windows prompts for these each time it is rebooted.

The proof is in the testing, so move position to a Microsoft Windows computer. You can use the Printers control panel to go through the steps of adding a network printer, or you might go for the quick keyboard method of clicking Start, Run, then typing \\computername where computername is the name of your Linux computer. After a short while, Windows will display all the shared folders and printers on that computer; you might not have any shared folders yet but all the printers you chose to share previously will now be listed.

Double-click on each printer; Windows will give a message alert that it is going to install drivers and set up a connection to the chosen printer. This is not an error message and is not any cause for alarm. You will be prompted, though, to supply a disk with Windows versions of the printer drivers.

Once complete, do try printing a test page. If this is unsuccessful, think clearly where the problem may have occurred and which step caused you difficulties. One of the most common problems I have faced with shared printers is that no matter how many times users insist they “get it”, people will invariably forget that to print to a shared printer, the computer which the printer is physically plugged in to has to be powered on and running. If the printer is plugged in to the back of a computer, then this computer most definitely has to be working in order to print to its printer.

This is Samba in a nutshell, and it will solve a good deal of Windows interoperability problems. The steps may have seemed lengthy but are all straightforward and logical.

First, share any printers you wish. install Samba. Next, configure its security settings. Fourthly, open the firewall to suit. Finally, try it from Windows.



Recently iTWire remodelled and relaunched how we approach "Sponsored Content" and this is now referred to as "Promotional News and Content”.

This repositioning of our promotional stories has come about due to customer focus groups and their feedback from PR firms, bloggers and advertising firms.

Your Promotional story will be prominently displayed on the Home Page.

We will also provide you with a second post that will be displayed on every page on the right hand side for at least 6 weeks and also it will appear for 4 weeks in the newsletter every day that goes to 75,000 readers twice daily.




Denodo, the leader in data virtualisation, has announced a debate-style three-part Experts Roundtable Series, with the first event to be hosted in the APAC region.

The round table will feature high-level executives and thought leaders from some of the region’s most influential organisations.

They will debate the latest trends in cloud adoption and technologies altering the data management industry.

The debate will centre on the recently-published Denodo 2020 Global Cloud Survey.

To discover more and register for the event, please click the button below.


David M Williams

David has been computing since 1984 where he instantly gravitated to the family Commodore 64. He completed a Bachelor of Computer Science degree from 1990 to 1992, commencing full-time employment as a systems analyst at the end of that year. David subsequently worked as a UNIX Systems Manager, Asia-Pacific technical specialist for an international software company, Business Analyst, IT Manager, and other roles. David has been the Chief Information Officer for national public companies since 2007, delivering IT knowledge and business acumen, seeking to transform the industries within which he works. David is also involved in the user group community, the Australian Computer Society technical advisory boards, and education.


Webinars & Events