- slide 1 of 5
Linux and Windows
One of Linux's greatest strengths has always been in its capabilities in a networked environment. Unlike Windows, Linux is completely open which allows people to make it work with other protocols, operating systems and the like. One of them is the SMB or the CIFS protocol. Developed by Microsoft for use in their own operating systems, the SMB/CIFS protocol is used by Windows operating systems in a network to exchange/share files and printers. Since it is completely locked down by Microsoft, there would be no chance of using another operating system in your network if you need to share files/printers across it.
Fortunately for us, the Samba project's goal has been to remove barriers to interoperability. It does this by making the Linux server look like a Windows File/Print Server which can then talk to other Windows servers in the network and exchange files or printers. This was done by painstakingly reverse-engineering the protocol by sniffing the network traffic. It is only now that Microsoft has been forced to open up the protocol so that other operating systems can interoperate using official specifications.
- slide 2 of 5
Installing And Setting Up Samba Client
In most feature-filled modern distributions today, atleast some form of a Samba implementation is installed out-of-the-box. This means that you can start exchanging files and start sharing printers without having to install anything. For example in Ubuntu, you can connect to a Samba server using the smbclient command and it will behave like an FTP client, allowing you to modify files using commands like ls, cd, dir. If you're scared of the commandline though, no need to worry. All Linux distributions with package managers will allow you to install the client/server package through their respective package managers.
Once installed, you might have to edit the configuration files manually, through a web-interface or through a graphical client supplied by your distribution or desktop-environment. For example, Gnome allows you to turn on Samba services using the Network Settings tool. In KDE, you can install a package called "kdenetwork-filesharing". If you're only going to share files in a Windows server, you don't need the Linux machine to act as a server. In this case, all you have to do is use certain commands to mount/browse Windows shares and exchange files with them.
You can mount Windows shares using the command mount.cifs. Here is a sample command which mounts "sharefolder" on the Windows server "ntserver" to the "mountpoint_for_windows_share" folder in /mnt. The username and password fields are self explanatory and you have to specify the username and password for the Windows server.
mount.cifs //ntserver/sharefolder -o username=pranav,password=mypassword /mnt/mountpoint_for_windows_share
If you're scared of commands, you can browse Windows networks graphically using tools which are generally built into all popular file managers like Nautilus. Once you have the Linux machine in the Windows network, it's as simple as connecting to a Windows share, specifying the username/password/domain combination and browsing the shared folders.
Once you're comfortable with the command and if you need to mount certain shares often or at boot time, you can add an entry for the share in your "/etc/fstab" file like this:
//ntserver/sharefolder /mnt/mountpoint_for_windows_share cifs users,username=pranav,password=mypassword,_netdev,uid=client_username,gid=users 0 0
Please note that the whole thing is one single line, and you can replace the single spaces between the parameters/options with tabs so that this line is aligned properly with the rest of the entries in the fstab file.
- slide 3 of 5
Setting Up Samba Server If you need to share files from the Linux server too, you will need to setup Samba server. This will make your Linux server act like a Windows server with File and Printer shares. Other Windows servers/computers will then be able to connect to it like they would connect to any other Windows server. Also learn where you can find graphical utilities to configure Samba server.
- slide 4 of 5
Setting Up Samba Server
If you do need to share files from the Linux server, you will need to setup Samba as a server. This will make it look like a Windows server with file/printer sharing. All the settings will be stored in a text configuration file, smb.conf. The Samba configuration file is generally located in "/etc/smb.conf" or "/etc/samba/smb.conf" depending on how your distribution's packagers handle it. A good guide on how to configure the Samba server manually can be found here. Although it is written and posted on Ubuntu's community site, the configuration file is the same for all distributions. You can safely learn the different tricks and apply them to your favorite distribution's samba package.
Important things to pay attention to in the smb.conf file if you're going to run it as a server are the share definitions. These blocks will setup the sharing from the Linux server and you can make or break it here. If you're not comfortable with the commandline configuration file editing, you can check out various GUI utilities like "Swat" to configure the samba server. Samba's website maintains a large list of graphical tools which can be used for different purposes like configuring a Samba server, graphical tools to browse Samba shares and certain applications to setup Samba using alternative authentication methods. Refer to your specific distribution's documentation to find out how you can install these tools.
- slide 5 of 5
The Samba project is one of the best proofs that a bunch of programmers driven by desire can beat a large company. The dedication shown by the Samba guys is commendable, especially after Microsoft resorted to changing the internal specifications for no other reason but to throw off the Samba project. Today, a Linux server can network with a Windows network as well as any other Windows server. The configuration and setting up of Samba has been made incredibly easy by the dedicated programmers hard-at-work on it. Refer to the manpages or online documentation if you run into any problems.