Samba Server (File Sharing) Setup

What is Samba?

Samba is a fascinating and powerful networking program.  Because of its level of complexity and multitude of uses, precisely defining it can be quite a challenge.  Here are three definitions found from the software’s developers, at

  1. “Samba is an Open Source/Free Software suite that provides seamless file and print services to SMB/CIFS clients.” Samba is freely available, unlike other SMB/CIFS implementations, and allows for interoperability between Linux/Unix servers and Windows-based clients.
  2. Samba is software that can be run on a platform other than Microsoft Windows, for example, UNIX (Mac OS X), Linux, IBM System 390, OpenVMS, and other operating systems. Samba uses the TCP/IP protocol that is installed on the host server. When correctly configured, it allows that host to interact with a Microsoft Windows client or server as if it is a Windows file and print server.
  3. Samba is a software package that gives network administrators flexibility and freedom in terms of setup, configuration, and choice of systems and equipment

Wikipedia provides this definition:  Samba is a free software re-implementation of the SMB/CIFS networking protocol, originally developed by Andrew Tridgell. As of version 3, Samba provides file and print services for various Microsoft Windows clients and can integrate with a Windows Server domain, either as a Primary Domain Controller (PDC) or as a domain member. It can also be part of an Active Directory domain.

To me, Samba at a high level, works like this:  In a meeting room in the United Nations are ambassadors from the Ukraine, Brazil, Spain, England, France, and Germany.  As six different languages are spoken, translators are needed so each ambassador knows what the other ambassadors are saying.  Samba functions like the translators, in that it allows computers with different operating systems to speak with each other, and like the ambassadors, it facilitates the computers in working with each other.

Assume, that in an office there is a computer network composed of an iMac, a Macbook Pro, several Window’s machines running XP, one Window’s machine on Window’s 7, and a file server running Linux.  Here are a few of the things Samba can do here:

  1. All the computers can connect and share files with the Linux server.
  2. For security, access to the server is granted by having each user provide a unique username and password.
  3. Like Unix, permissions are granted to a user, groups, and everyone else; however, Samba’s permissions are a second level of access/use to the permissions already in place through the Linux server’s file system. Similarly to the server’s permissions, users can have restricted access and use of some files, and full access and use to others.
  4. Natively, Windows machines can share files with each other.  Also, Macs can natively share files with other Macs.  With Samba working on the Macs, all the Window’s and Mac computers can share files with each other.
  5. A Window’s user can share a printer attached to a Mac, or the Mac’s user can share a Window’s printer.

Our Goal

There is a great deal of documentation on how to obtain, install, and configure Samba. is the first place to go for additional information.  In addition, there are quite a few books published on the subject.  Samba is indeed complex, but so is Adobe Photoshop.  I have used Photoshop both personally and professionally for years, and I still feel I have not scratched the surface of knowing everything the software is capable of doing.  I can say the same thing for Word, Excel, Access and many other programs.  What I can do with each of the examples of software I just mentioned is get from them enough functionality to meet my needs.  In some cases, I am using 60% of the software’s potential, and in some cases, I use only 10%.  When you think about it, I believe this outcome in not uncommon.  With regards to Samba, you only need to know how to use a small portion of Samba’s functions to have a safe and secure home or small office network.  Showing you that “small portion” is the goal of this document.

You will need…

We will be setting up Samba on a Server, using an installed Ubuntu 12.04 as its operating system and as a point of reference.   As this operating system does not have a graphic user interface, we will be using the terminal program to setup and configure Samba.  As a result, you will need familiarity with Linux/Unix file permissions, and some basic terminal commands.  If you are unfamiliar with permissions, or using the terminal, to help you proceed and to understand fully what is going on with the Samba configuration process, please read the article in this blog written 8/07/2012, Linux and Unix File Permissions

As we need to configure Samba, it first must be installed on the system.  On Ubuntu Server, you can install Samba by selecting it as one of Ubuntu’s install options, when you initially load Ubuntu onto your hard drive.  If you have another Linux distribution already installed, you may have the entire Samba program installed, or just the Samba client (allows you to access Samba files on another PC with Samba).  Here is a way to see if your server software is installed and working:

1.  Because we will be using the command line throughout this process, become “root”, so you have full administrative permissions (some distributions may not allow the process in the example below, so simply type su and then enter). After you press Enter, you will be asked to supply passwords.  If you leave (shut down the terminal) for any reason during this exercise, repeat the following process:

sudo-su Samba Server (File Sharing) Setup Discussions How To Linux OS X OS X Security Tips

2.  Enter the following and press Enter.  In the response, the first line should look similar to this:  root     3869     1   o  16:41?     00:00:00 smbd -F     We are looking for the Samba daemon (smbd).  This is your server service and runs in the background.  For a broader look, you can use the following command but change “smbd” to “smb”.  In any event you should see some activity pertaining to smbd (or smb in the later example).

smbd-running Samba Server (File Sharing) Setup Discussions How To Linux OS X OS X Security Tips

If smbd is not running, then you do not have the Samba server software installed.  On most Linux distributions you can get it and have it installed through the program’s package manager (sometimes called “synaptic package manager).  Package managers are usually found in System Preferences. For this example, on Debian Linux based distributions, you can also get it from the command line in the terminal by typing the following and pressing Enter:

apt-get Samba Server (File Sharing) Setup Discussions How To Linux OS X OS X Security Tips

Configuring Samba

To begin with, let’s create a file on our server to share.  The file is called “Stuff”.   It will be  located in another folder called “Main” in the “mnt” directory.  The following command will create both “Main” and “Stuff”.  Be sure you have administrative privileges (Item 1., above).

mkdir Samba Server (File Sharing) Setup Discussions How To Linux OS X OS X Security Tips

Now, we need to change the owner and group of the file.

chown Samba Server (File Sharing) Setup Discussions How To Linux OS X OS X Security Tips

Next, we need to change to file permissions.

chmod Samba Server (File Sharing) Setup Discussions How To Linux OS X OS X Security Tips

We are now off to find the Samba configuration file, called smb.conf.  You will need to press Enter at the end of each line.

find-smb-conf Samba Server (File Sharing) Setup Discussions How To Linux OS X OS X Security Tips

Let’s see what’s in the Samba file.

long-list-samba Samba Server (File Sharing) Setup Discussions How To Linux OS X OS X Security Tips

You should now be looking at the list of files in the Samba folder of directory “etc”.  We are looking for the file smb.conf.  You may only see the file smb.conf.sample, or some other variation of smb.conf.  In any event, this is a large document, most of which are scripted arguments you will probably never need, but are there, “just in case”.  We are going to assume the only configuration file available to us is smb.conf.sample.  We will back it up so we have a fresh copy.

smb-backup Samba Server (File Sharing) Setup Discussions How To Linux OS X OS X Security Tips

Now, we change the name of smb.conf.sample to smb.conf.

smb-name-change Samba Server (File Sharing) Setup Discussions How To Linux OS X OS X Security Tips

To configure Samba, we need to edit this file.  To accomplish this, we will need to use a text editor.  At the command line, usually vi or pico are available.  If you are using Kde as a graphic user interface, then kwrite is available, and if you are using Gnome, then gedit will work.  For my example, I will use vi (replace vi with the name of your editor).  Once again, be sure you are root and/or have administrative privileges.

load-smb-conf Samba Server (File Sharing) Setup Discussions How To Linux OS X OS X Security Tips

Now you’ll see something like document below.  When I saw if for the first time, I said, “Yikes”.  It really isn’t so bad.  The document (at this point only a portion of the document is visible) is broken down into service areas.  In each service area, there is text explaining a setting or an action, followed by the actual setting or action.  Note that each line of text begins with a “#”, and the beginning of the line with the setting or action begins with “;”.  Both symbols are telling Samba to ignore the line.  When you delete the “;” at the beginning of the setting or action line, that item will become active and used by the program.

smb-conf_1 Samba Server (File Sharing) Setup Discussions How To Linux OS X OS X Security Tips

Samba configuration files vary often from one Linux distribution to another, and are also updated by Samba developers as well.  So it is possible that the lines I am asking you to activate, are in different Service sections in your smb.conf file than are shown in the examples.  The lines you need to activate will still be in your smb.conf file.  On the above page, find the red arrow.  If there is a semi-colon beginning on the line, delete it.  Using your curser keys, move the curser to a position after ” workgroup =” and place the name of your workgroup.  In the example, I creatively used the name WORKGROUP.  On the section below, delete the semicolon before security = user, and encrypt passwords = true.  You may see other lines without semi-colons as well, they are default settings, so do not touch!!!

smb-conf_2 Samba Server (File Sharing) Setup Discussions How To Linux OS X OS X Security Tips

Delete the semicolons on the two lines by the arrow.  They may or may not have any effect on Samba’s performance.  I have had pretty good luck with the socket options line.

smbconf_3 Samba Server (File Sharing) Setup Discussions How To Linux OS X OS X Security Tips

Below are examples of files set up to share with other computers.  At the very end of your smb.conf file, in a service section called “Shares” or “Share Definitions” copy exactly the share for “Stuff”.  This will direct Samba to use that file share made earlier in this exercise.  This share will allow the file “owner”, and the group “users” to have read, write, and execute permissions to the file “Stuff”.  “Everyone” else will only be able to see the file contents.

smb-conf_4 Samba Server (File Sharing) Setup Discussions How To Linux OS X OS X Security Tips

At this point, if you used a graphic interface, you can press File and Save from your editor’s menu bar.  From vi or pico, hold the control key and depress the letter “o” on the key board.  You will then be asked if you want to save the information and you type in “Y” or “yes”.  In a second, the editor will tell you it wrote a number of lines to the file smb.conf. You then hold down the control key again, and depress the letter “x” to exit.

Update (9/27/2013) :  When I write an article like this, I have a computer sitting next to me, and I verify that commands and entries do in fact work.  When I originally wrote this article, I had an AMD based server using Ubuntu Server software (12.04).  Every example I used in the article checked out.  That’s the good news.  The bad news is that for some inexplicable reason, I have not been able to replicate those results.  If you are struggling with the shares as listed in the above example, change the line:  valid users = @users to valid users = yourusername.  Now the share should work.  Be sure to create a smb password for this user. 


Usually, for home users, individual users for the operating system are created when the program is installed.  In a business environment, this is an ongoing process.  If you are using a Linux version with a graphic user interface “users and groups” are usually initiated or changed in system preferences.  This can be done at the command line too.  Again, before you start, be sure you are root or have administrative privileges.  By typing in the text below and pressing Enter, larry becomes a user, and also adds larry to the group “users”.  Be sure the name has no capital letters.  After you press Enter, you will prompted for a password.

useradd Samba Server (File Sharing) Setup Discussions How To Linux OS X OS X Security Tips

You now need to use the user name and password to set up your Samba account.  After you press Enter, you will be prompted for a password.

smbpasswd Samba Server (File Sharing) Setup Discussions How To Linux OS X OS X Security Tips

Checking Everything Out

At this point, Samba has not read the configuration file.  So the best thing to do now is to “refire” Samba back up so that everything is running and our changes are activated.  There are a number of ways to start and stop Samba, and it varies by Linux distribution, so the simplest method for us now is to reboot your computer.  Once you have rebooted your computer, go back to your terminal and type the following:

testparm Samba Server (File Sharing) Setup Discussions How To Linux OS X OS X Security Tips

Testparm will test the parameters in the smb.conf file.  When it is done, it will print to your monitor something like this:

testparm-info2 Samba Server (File Sharing) Setup Discussions How To Linux OS X OS X Security Tips

Here, testparm has checked the smb.conf files, made a change to rlimt, and processed my service files and found no errors.  If one would press the Enter key as prompted, it displays the same mentioned processes as written in the smb.conf file.  If you have errors, testparm can supply a “heads-up”.  If there is a problem with your file share “Stuff”, make sure your entry in smb.conf is correct, and that the file “Stuff” is in /mnt/Main, and that your permissions are correct.

At this point, you should be able to launch your Mac, and under Shared in your Finder window, or in Network Neighborhood on your Window’s machine, and find the host name of your Samba Server there.  Click on the name, you will be asked a username and password, and then you should see the folder “Stuff”, click that icon, and you will see an empty file.  Copy some documents and files there.  Samba is ready to go.


Find out more about Samba by going to, and reading the documentation there.  This is a powerful program, and you have only used a few pieces of it.  I hope this document was helpful and that you enjoy the program.

By prometheus

Husband. Father. Grandfather. World class Geek.

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.