Setting Up a Samba Share to Share Files with Windows

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.

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 in 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 like we did during the Suse 10 installation  when we chose a host name 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 click the Shares tab to setup 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 modification 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 neccesarily 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 setup 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.

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. Its 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 becuase 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 host name I setup on my Suse machine but I could put whatever I want for host name mappings like
172.16.0.21    hamsandwich

This will resolve the host name(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 whatver host name you put in your hosts file.

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

   

Books


I just got this book recently but I wish I had got it when I was first starting to learn linux as it would have saved me a lot of struggle. It answers a lot of the how to questions and will give you confidence in using the command shell.


This book is a great desk reference compendium of linux shell commands useful for all distributions.


This is a great MySQL book. Read through it and keep it handy as a reference.


This is a great MySQL book if you need to scale to a whole lot of users. Jeremy Zawodny is a super guru with real world experience squeezing the most out of MySQL for Yahoo!


This is the definitive book for PostgreSQL, the most advanced open source database.
Donate Money to support the mojoPortal Project. View Joe Audette's profile on LinkedIn View Joe Audette's profile on The Guild of Accessible Web Designers site