This brief tutorial shows you how to easily install and configure Samba file sharing on Ubuntu 14.10. With Samba, one can share files and folders with users on other machines like Windows, Mac OSX or other Linux machines.

The process is pretty easy. Just install Samba and other Samba related tools and start sharing resources. Resources could be printers, CD/DVD drives or files and folders.  Before we get started, here’s what we’re going to do:

  • Create a local host record to point to the server IP (If no DNS systems are in place)
  • Create a local a domain or workgroup and add both the server and client computers in it
  • Enable sharing from the server and allow the clients to access files/folders

For this tutorial, we’re going to name the server SRV01 and assign an IP address

Our clients computer will fall into the same IP subnet using and up. 

The first thing we need to do is verify that all the systems are in the same workgroup, both the servers and clients. To check the workgroup on Windows machines, open the commands prompt and type the command below.

net config workstation

You should see the workgroup it belongs to.. The best ways is to use the current Workgroup Windows machines belong to. The default workgroup is ‘Workgroup‘ so we’re going to be using it on all our systems.

C:\Users\Richard>net config workstation
Computer name                                           \\WIN8
Full Computer name                                    WIN8
User name                                                      Richard
Workstation active on
Software version Windows 8.1 Enterprise
Workstation domain                                   WORKGROUP
Logon domain                                              WIN8
COM Open Timeout (sec) 0
COM Send Count (byte) 16
COM Send Timeout (msec) 250
The command completed successfully.

Next, go and configure the local host records for the client computers if DNS systems are not in place. To do that, open the command prompt as administrator and run the commands below.

notepad C:\Windows\System32\drivers\etc\hosts

That should open the hosts file. Then enter the host record for the server and save.. The format is IP address followed by the the domain name and hostname                                   SRV01

After that, save the file and close out.

Next, logon to Ubuntu server and install Samba and other tools. To install these packages, run the commands below.

sudo apt-get install -y samba samba-common python-glade2 system-config-samba

Next, create a backup of the existing Samba’s configuration file. To do that, run the commands below.

sudo mv /etc/samba/smb.conf /etc/samba/smb.conf.bak

After that, create a new Samba config file with the global info below.

sudo vi /etc/samba/smb.conf

workgroup = WORKGROUP
server string = Samba Server %v
netbios name = srvr1
security = user
map to guest = bad user
name resolve order = bcast host
dns proxy = no

Save the file.

At this point, we have our basic Samba configurations but no shares available. The [global] block above defines what workgroup the server belongs, what security levels is used and what NetBios name to display to clients.

For example, if you wish to share a folder where everyone has access and not security, then follow the steps below.

Create a shared folder called allaccess by running the commands below.

sudo mkdir /samba/allaccess

Then give all users access with full control. To go that run the commands below.

cd /samba
sudo chmod -R 0755 allaccess
sudo chown -R nobody:nogroup allaccess

Next, create a share block called [allaccess] in Samba configuration file as shown below.

path = /samba/allaccess
browsable = yes
writable = yes
guest ok = yes
read only = no

The configuration file should look like this

workgroup = WORKGROUP
server string = Samba Server %v
netbios name = srvr1
security = user
map to guest = bad user
name resolve order = bcast host
dns proxy = no
#============================ Share Definitions ==============================
path = /samba/allaccess
browsable =yes
writable = yes
guest ok = yes
read only = no

After saving the file, restart Samba using the commands below

sudo service smbd restart

Now you should be able to access the share by browsing using Windows Files Explorer

Samba Configuration in ubuntu


To create secured shares so only members of a particular group can access, follow the steps below.

Create a secured folder by running the commands below

sudo mkdir -p /samba/allaccess/secured

Then create the secure group by running the commands below

sudo addgroup securedgroup

After that, give the group full control of the secured folder. To do that, run the commands below

cd /samba/allaccess
sudo chmod -R richard:securegroup secured
sudo chown -R 0770 secured/

After creating the secured folder, go and add another share block in the Samba’s configuration file.

path = /samba/allaccess/secured
valid users = @securedgroup
guest ok = no
writable = yes
browsable = yes

Save Samba configuration file after the change above.

Now, only members of the securdgroup will have access to the secured folder. So, to give new member access, just add them to the securedgroup. To do that, run the commands below.

sudo usermod -a -G securedgroup richard

(replace richard with the account name of the user)

For each of the member to have access, he/she must be in Samba access database. To add a user, run the commands below against the username

sudo smbpasswd -a richard

The command above will prompts for a new password. Create and confirm the password. This password will be used to access shares.

Restart Samba database again and all members in the securedgroup should have access to the Secured folder.

sudo service smbd restart