A Quick Guide to Samba

Posted Jun 28, 2006 | by jordma01  

Is this for me?
Ever wanted a simple, low cost way to make files available to every computer on your home network? This guide will teach you how to do just that, using a combination of Linux and Samba. What is Samba? Samba is an open source project that provides a highly configurable and tweakable fileserver for the Linux operating system.


At this point you may be asking yourself “Why don’t I just make a shared folder on one of my Windows computers?” There are several advantages to using Samba as a file server. First, and perhaps most importantly, it’s free. Completely free. (At least the software is, you can’t make the computer to run it on appear magically out of thin air.) The second reason is that it’s a good way to take advantage of an old unused computer you might have sitting around. Even a computer as slow as 500 Mhz will run a Samba server just fine, so if you have any old computers around you might as well give it a try. Finally, Samba is very customizable and tweakable, offering much more detailed control than Window file sharing. In this guide you will learn how to:



  • Install Samba

  • Configure Samba

  • Set Linux file permissions

  • Add users and start Samba

  • Connect to your file server from a client PC


Initial Setup
Now that you’ve decided to give it a try, let’s move on to setting it up and making it work right. The first thing you need is to install Linux. Jason Faulkner has given us an excellent article on installing Ubuntu, a very user friendly version of Linux. If you’re new to Linux I would suggest following his guide to get it up and running.


Once you have Linux up and running, it’s time to install Samba. From the Ubuntu command line, get root access by typing in “su” and then entering the root password. Stay in root for the remainder of this article, and type “exit” at the end to become a normal user again. Now enter “apt-get install Samba”. You should note that depending on the Linux distro you have installed and your configuration options, it is very possible that Samba is already installed. Throughout the rest of this guide I will assume that you are working with Ubuntu Linux. If you are using a different distribution, some things may be installed in slightly different places than what I refer to.



Configuration
Now that you have Samba installed it’s time to configure it. All of the configuration for Samba is done in the file /etc/samba/smb.conf. There are countless options available in this file, but you do not need to worry about most of them for our setup. For a full explanation of each option, use the man program built into Linux by typing “man smb.conf” into the terminal. Use the arrows to move through the file and press q to quit. Next we need to set up the configuration file. I prefer the pico text editor to edit files in Linux, so to edit the file I enter “pico /etc/samba/smb.conf” and make my desired changes. Once you are done editing the file press control+x to exit and press y to save the changes and then leave the file name as is and press enter to finally save the changes. An example of a configureed smb.conf file is below.

     [global]

         workgroup = MSHOME

         netbios name = files

         security = SHARE

       

[media]

         path = /home/media

         browseable = Yes

         guest ok = Yes
     [private]

          path = /home/matt/files

          browseable = Yes

          valid users = matt

          writelist = matt

In the global section we place settings that affect the entire server. The workgroup name is what workgroup the server will appear under when we browse the Network Neighborhood, or My Network Places from Windows. The netbios name is the name of the server. You can leave this line out and it will simply be your hostname. The security line has a couple different options appropriate for us. If it is SHARE, everyone will be given access to the server when the log on and it will not prompt for a username and password. In this situation it automatically uses the same username and password that you are logged into Windows with. If you change it to security = USER, it will ask for a username and password whenever any user tries to access the server. After the globals section there is an entry for each share. The part in brackets is the name of the share as it will appear to any clients accessing it. Again, there are many settings available for each share, but we only need a few to get us up and running. The path is simply the actual file path which the share will map to, and the browseable setting determines if the share will show up with network browsing from Windows. If this is set to “No”, one must type in the complete path to have access to the share. The guest ok setting simply determines if anonymous users are given permission to access that particular share. In my above example, everyone has access to the media share and only matt has access to the private share.

Which Of These Traits Applies To YOUR Computing Life?...

Leave a Reply