Setting Up a Samba Share to Share Files with Windows

Joe Audette

Updated

If you’re going to be developing in VS.NET on Windows and deploying/testing on Linux, you’re going to need an easy way to share files between them. In this article, we will walk through setting up a Samba share on your Suse 10 machine that you can map as a drive on your Windows machine.

To start, click the House icon in the lower left of your Suse 10 desktop to open a File Manager as a normal user. This will put you in your home directory which is normally /home/yourusername, in my case it is /home/frodo

Next, we will create a new folder in our home directory and name it Webshare. Click the Edit Menu and choose Create New > Folder, then enter the name of the folder.

Setting Up a Samba Share

You have probably figured out by now that Linux lets you have as many desktops as you like. I have configured 6 of them as you can see 1 through 6 in the menu bar at the bottom of my screen (above).

To configure how many desktops you can right-click in one of the numbered squares in the menu bar and choose Configure Desktops. In the screen above Desktop 1 is active and I have my File Manager open on that desktop.

Next, click on desktop 2 and we will open YaST on this desktop. System > Control Center (YaST), you will be prompted for the root password.

As shown above, click the Network Services item on the left then click Samba Server to configure Samba and add our new webshare folder as a share.

You will be prompted for a domain name. If you have a local domain name enter it here. If not feel free to make something up as we did during the Suse 10 installation when we chose a hostname and domain in the network settings. I put middleearth.home for mine as shown below.

I don’t have a domain controller on my local domain at home and I don’t want to configure Samba as a domain controller, so I checked Not a Domain Controller.

Next, I set it to start Samba during bootup then I clicked the Shares tab to set up my share. Also, be sure to check the box and open a port in the Firewall to allow your local network to access the share.

Now I create a share named webshare that points to my /home/frodo/webshare folder. I unchecked inherit ACLs and unchecked Read Only.

Next, Click Finish as shown below.

I had to do some modifications to the configuration file for Samba to get the share to actually work for me. I’m in no way a Samba or Linux guru yet myself so don’t think this is necessarily the best practice but this is what worked for me and it should work for you.

If someone with more expertise out there wants to email me with a better procedure I will update this article happily. You’ll need to open System > File Manager > File Manager Super User Mode to do this because only root has permission on the configuration files.

Now browse to /etc/samba/ and open smb.conf in a Text Editor

Scroll to the bottom of the file and you’ll see the section for the share you just set up in YaST. Add the missing settings as shown above, of course, put your Linux user name where I have Frodo. Now save and close the file.

samba sharing

Before I move on I’d like to talk a little about Linux configuration in general. While there are some nice GUI tools like YaST for configuring many of the settings on your Linux machine, most of the GUI configuration tools are really just a front end on top of text files where the settings are stored.

Almost everything you will ever need to configure is located in a text file somewhere below the /etc folder. It’s just a matter of knowing which file has which settings and what the possible options are for each setting.

There is a lot of documentation available for these settings both online and in the man and info pages locally on the Linux machine Those coming from a Windows world sometimes perceive this as an indicator that Linux administration is difficult.

But think about it, as an ASP.NET developer you are probably very familiar with storing settings for your web apps in the Web.config file, and editing these settings seems trivial to you. When you are familiar with the file and the settings it seems very easy and the fact that all you need is a text editor is very convenient isn’t it? I say this because this is a paradigm shift I went through.

I used to think Linux administration was difficult and then as I became familiar with the files and settings of interest to me my point of view changed.

Now getting back to setting up the share, we now need to restart the Samba service for our setting changes in the smb.conf file to take effect. Open YaST again or switch to the desktop where you already have it open if you still have it open. Then as shown below click System in the left pane and then System Services (Runlevel)

This is where you can configure which services are running similar to what you would do on Windows using the Service Management Console.

Click on SMB Samba File and Print services as shown above then click Disable to stop the service

Now after it stops click it again and then click Enable to start the service again.

Now while you’re in the services administration section of YaST, scroll up the service list and see if apache2 is already running. If not start that service as well by clicking it then clicking Enable. Now click Finish and it will save your settings.

Now most likely you are like me and working at home so you don’t have a Domain Name Server (DNS) to resolve names of the computers on your local network. Since I want to be able to connect to my Suse 10 machine by name I will create an entry in my hosts file to map a friendly name to the IP address of the Suse 10 machine. On Windows, this file is typically located at
c:\Windows\system32\drivers\etc\

Interesting that we also have an etc folder on Windows, isn’t it? Anyway, the hosts file in that folder is just a text file, you can open it in Notepad or a text editor of your choosing (Don’t use a Word Processor)

You will see a line with 127.0.0.1 localhost this is how every machine knows that the hostname localhost refers to itself. The use of localhost is a conventional naming on both Windows and Linux. 127.0.0.1 is what is known as the loopback IP address because it always points to the machine you are on.

Now we will add the IP address of your Suse 10 machine with a friendly name of your choosing. I put the following 2 lines:
172.16.0.21 isengard
172.16.0.21 isengard.middleearth.home

Note that you can map multiple names to the same IP address. I chose names that correspond to the hostname I setup on my Suse machine but I could put whatever I wanted for host name mappings like
172.16.0.21 hamsandwich

This will resolve the hostname (s) I put to the IP address I put at least for this Windows machine. Save the host file and then in a web browser on your Windows machine go to http://isengard (or whatever host name you put) and you should see the default Apache web page served from your Suse 10 machine. Nice huh?

Finally, open Windows Explorer and choose Tools > Map Network Drive, then pick an available drive letter, and for the Folder put \isengard\webshare (of course replace isengard with whatever hostname you put in your hosts file.

Stay tuned for the next article and we will finally learn to set up mojoPortal on the Suse 10 machine using Apache Virtual Hosts. Learning this will allow you to set up as many sites as you like on your Suse 10 machine so you can develop and test your own applications.